Basics

What is a presigned URL — a link that lives an hour and acts as you

Illustration: a paper pass with an hourglass in front of a closed warehouse door

Here's the surprise. A signed link to a file isn't a secret address "nobody will guess". It's a temporary pass issued in your name: the Amazon S3 docs say it outright — the link carries the permissions of whoever signed it. For those few minutes, whoever holds the link is you.

And the second surprise, the one almost everyone trips on: the link is not single-use. It works as many times as you like until it expires.

Let's unpack how it's built — and why it's the neatest way to hand over a private file.

What a presigned URL is, in plain words

A presigned URL is the ordinary address of a file in object storage, with a signature and an expiry stapled on.

The point is to keep the browser away from your access keys. The flow looks like this:

  • the browser asks your server: "give me contract 42";
  • the server checks this user is allowed that contract, then signs a link with its key;
  • the browser follows the link straight into storage, bypassing your server;
  • fifteen minutes later the link turns into a pumpkin.

Your code only ever touches the string with the address — the bytes never flow through it. Keys stay on the server, and nothing reaches the browser except a string that merely looks disposable.

What's baked into the link

Look at one with your eyes: after the question mark there are a few parameters. The important ones:

  • X-Amz-Expires — how many seconds the link lives;
  • X-Amz-Date — the moment of signing, which the expiry counts from;
  • X-Amz-Signature — the signature itself;
  • X-Amz-Credential — whose key signed it.

Storage recomputes the signature on arrival and compares. Match plus time left — you get the file. Change one character (say, swap in a different file name) and the signature no longer adds up, so you get a refusal.

The maximum lifetime is 604,800 seconds — seven days. Not an arbitrary rule: the signing key itself is valid for up to seven days, so there's physically nothing to sign a longer one with.

The big misunderstanding: it's not a "secret link"

Since the link opens repeatedly, treat it like a house key, not a one-time SMS code.

  • Forward it into a group chat and everyone in that chat has the file.
  • Let it land in a server log or an analytics event, and anyone with log access has the file.
  • You can't revoke it. The only ways to "switch it off" are to wait it out, delete the object, or strip permissions from the key that signed it.

Hence the rule: set the expiry from the scenario, not "generously, just in case." An avatar on a page — minutes. A report export someone downloads right now — 5 to 15 minutes. A link in an email read in the evening — an hour. Seven days is almost always wrong.

Uploads work the same way — and here's the trap

You can sign "upload", not just "download". The browser then sends the file straight into storage, and your server's request-size limits stop existing as a category.

But there's a catch AWS calls out separately: if an object with that key already exists, the upload replaces it. Silently, no questions.

So two rules for write links:

  • the key is invented by the server, never by the browser — otherwise a user sends users/1/avatar.jpg and overwrites someone else's avatar;
  • put something random or a user id into the key so two people never collide on one name.

Why the link died early

The classic riddle: you set seven days and everything broke after an hour.

The cause is nearly always the same: the link was signed with temporary credentials. Code running under a role — on a cloud server, in a serverless function — doesn't hold a permanent key, it holds a short-lived one. A link can't outlive the credentials that signed it: the role session ends, the signature is dead, whatever you wrote in X-Amz-Expires.

The fix: either sign long links with a permanent key kept in environment variables, or accept a short expiry and re-issue the link on demand. The second is more honest and usually simpler.

Can I revoke a link I already handed out?

Not individually. Only blunt instruments work: delete the object, rename it (which means copying it under a new key), or remove permissions from the signing key — which kills every link it ever signed. That's exactly why a short expiry beats any "revoke" button.

Can I sign the link in the browser?

No. Signing needs a secret key, and anything that reaches the browser counts as public. Signing lives on the server: a backend, a serverless function, an edge function. A nice detail in Supabase Storage: signatures there use a dedicated internal key, separate from the one that signs session tokens.

How is this different from a public bucket?

A public object is served to everyone, always — the right call for covers, icons and logos. A signed link is for files that belong to one person: documents, receipts, data exports. How to wire that up is in how to keep user files private.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →