Imagine your SaaS application lets a user share a private document with someone else.

You generate an S3 presigned URL and send it to the recipient. The link works. Then the owner revokes access.

What happens to the URL?

The uncomfortable answer is that you cannot revoke an individual S3 presigned URL directly.

You can make it stop working through broader actions, such as deleting the object or changing the permissions that allow it to be accessed. But S3 does not provide an API to revoke one specific presigned URL while leaving everything else untouched.

This matters when you're building applications where file access can change independently of the underlying object.

How an S3 presigned URL works

A presigned URL is a signed request.

Your application generates it using credentials with permission to access an S3 object. The URL contains the information S3 needs to validate the request, including its signature and expiration.

When someone uses the URL, S3 validates it directly.

Your application is not involved in that request.

That is the key detail.

Once the URL has been issued, S3 does not ask your application whether the user still has permission. It checks whether the signature is valid, whether the credentials are still valid, and whether the request is otherwise authorized.

If the URL is still valid, the request can succeed.

Your application may have revoked the user's access in its own database. That change does not automatically invalidate a URL that S3 can still validate.

How long can an S3 presigned URL remain valid?

The maximum lifetime depends on the credentials used to sign it.

Credential type Relevant expiration
IAM user credentials Up to 7 days with Signature Version 4
IAM role credentials The URL expires when the role session expires, even if a longer URL expiration was requested
EC2 instance role credentials Typically up to 6 hours
Temporary credentials The URL cannot outlive the temporary credentials

Sources:

There is another detail worth knowing: S3 checks expiration when the HTTP request begins. A download that starts before expiration can continue after the expiration time. A new request made after expiration will fail.

So expiration is not the same as actively revoking an already-issued link.

What can you do to invalidate access in S3?

There are several ways to make a presigned URL stop working, but each has a broader effect than revoking one individual link.

1. Delete the object

Deleting the object makes the URL unusable because the resource it points to no longer exists.

This is simple, but it is not appropriate when you want to revoke access while keeping the file.

2. Change bucket permissions or policies

A bucket policy can deny requests that would otherwise be allowed.

For example, s3:signatureAge can restrict how old a signature may be.

This can be useful as a security guardrail, but it applies at the policy level. It is not a per-link revocation mechanism.

Source: AWS presigned URL best practices

3. Deactivate or rotate signing credentials

If you deactivate the credentials used to sign URLs, URLs signed with those credentials can no longer be used.

The downside is scope: this affects other URLs signed with the same credentials too.

4. Revoke role sessions

AWS provides mechanisms to revoke active role sessions.

This can invalidate access associated with those sessions, but it is not a way to target one individual presigned URL without affecting other access associated with the session.

The common theme is that AWS gives you ways to invalidate access at a broader level. It does not give you a native per-URL revocation operation.

What about Supabase Storage and UploadThing?

This is not only an S3 consideration. Different file platforms make different trade-offs.

Supabase Storage

Supabase documents that individual signed URLs cannot be revoked directly.

Its documented approach includes rotating the signing key, which revokes URLs signed with the previous key. This is a broader operation, not individual link management.

There is also a caching consideration: cached responses may remain available until the relevant cache entry is purged or expires.

Sources:

UploadThing

UploadThing documents signed URLs that remain valid until their expiration or until the associated API key is deleted or revoked.

Its UTApi supports a maximum presigned URL duration of seven days.

Again, API key revocation is broader than revoking one individual link.

Sources:

These services have different APIs and operational models, but the underlying design question remains: where does the application make the decision about whether a file can still be accessed?

A different model: make the link a database record

If your application needs individual revocation, usage limits, or access decisions that can change after a link is created, the application needs to remain involved.

One approach is to represent a shared link as a database record.

Instead of treating the URL itself as the complete authorization mechanism, treat it as a reference to a decision your application can still change.

A simplified table might look like this:

CREATE TABLE file_links ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), file_id UUID NOT NULL, secret_hash TEXT NOT NULL, expires_at TIMESTAMPTZ, revoked_at TIMESTAMPTZ, max_uses INTEGER, use_count INTEGER NOT NULL DEFAULT 0, created_at TIMESTAMPTZ NOT NULL DEFAULT now() ); 

The URL contains a random secret. The database stores its hash, not the original secret.

When someone opens the link, the application:

  1. Extracts the secret from the URL.
  2. Hashes it and finds the matching record.
  3. Checks whether the link has expired.
  4. Checks whether it has been revoked.
  5. Checks whether its usage limit has been reached.
  6. Authorizes access to the underlying file.

Revocation becomes a database operation:

UPDATE file_links SET revoked_at = now() WHERE id = $1; 

The next request checks the record and rejects the revoked link.

The important difference is that the application makes an authorization decision every time the link is used.

The URL is no longer the entire authorization mechanism.

The concurrency problem with usage limits

There is a subtle issue if links have a maximum number of uses.

Imagine a link with max_uses = 1.

Two people open it at almost exactly the same time.

A naive implementation might:

  1. Read the current usage count.
  2. Check that it is below the limit.
  3. Increment the usage count.
  4. Serve the file.

Both requests can read use_count = 0 before either one updates the row.

Both may then serve the file.

The limit has been exceeded.

A database constraint can help prevent invalid states, but it does not make a separate read and update atomic.

The better approach is to combine the check and increment into one conditional database operation.

For example:

UPDATE file_links SET use_count = use_count + 1 WHERE secret_hash = $1 AND revoked_at IS NULL AND (expires_at IS NULL OR expires_at > now()) AND (max_uses IS NULL OR use_count < max_uses) RETURNING file_id; 

If the operation returns a row, the request has successfully claimed a use. If it returns no row, the link is invalid, expired, revoked, or exhausted.

The conditional update makes the decision and the increment one atomic operation.

A CHECK constraint is still useful as a final integrity guard. In the tested race condition, it turns a silent overshoot into a database error (SQLSTATE 23514) for the second visitor. That is better, but the single conditional UPDATE above is the actual fix.

Here are the results from testing the conditional update against the guide's own table implementation (share_link, including max_downloads and download_count):

Concurrent requests Maximum uses Requests served
2 1 1
10 3 3
20 1 1
50 7 7

The reproducible test is available in docs/guides/expiring-and-revocable-file-links.proof.mjs.

This is a small example of why file sharing is not just a URL-generation problem. It is also a database consistency and authorization problem.

What if you still want to use presigned URLs?

You do not necessarily need to choose between application-level authorization and object-storage presigned URLs.

A hybrid approach is possible:

  1. The user opens an application-controlled link.
  2. Your application checks the database record.
  3. Your application verifies that access is still allowed.
  4. Your application generates a short-lived S3 presigned URL.
  5. The client is redirected to the object.

This gives you a place to enforce revocation before issuing the storage URL.

There is still a window between issuing the presigned URL and its expiration. During that period, the URL can be used independently of your application.

The shorter that expiration window, the smaller the exposure.

This pattern is useful when you want application-level authorization without proxying every file download through your own servers.

Do not forget about caching

There is another problem that can undermine revocation: HTTP caching.

Imagine that a user successfully opens a shared file. A proxy, browser, or CDN caches the response. The owner then revokes the link.

Even if your application rejects the next request, a cached response might still be served without reaching your authorization logic.

For sensitive downloads, use an appropriate cache policy. For example:

Cache-Control: private, no-store 

This is not a substitute for authorization, but it helps prevent private file responses from being reused from caches.

In an earlier version of my own implementation, a missing Cache-Control header allowed a revoked link to be replayed from cache in an adversarial test.

That was a useful reminder: revocation is not complete if another layer can still serve the content.

When should you use each approach?

Presigned URLs are useful. They are a simple and effective way to grant temporary access to an object.

They work particularly well for short-lived downloads, one-time workflows, and cases where the expiration window is an acceptable security boundary.

An application-controlled link is more appropriate when you need:

  • Individual link revocation.
  • Usage limits.
  • Current permission checks.
  • Workspace or tenant-level authorization.
  • Audit events for access attempts.
  • Sharing rules that can change after link creation.

The decision depends on the access model your application needs.

If the requirement is simply "let someone download this file for the next five minutes", a presigned URL may be all you need.

If the requirement is "let this person access this file until the owner revokes permission", the application needs to remain part of the authorization path.

The bigger lesson

Object storage solves the problem of storing and retrieving objects.

A SaaS application often has another problem: managing files that belong to users, teams, and workspaces, with permissions and lifecycle rules that can change over time.

That application-level responsibility includes ownership, authorization, sharing, expiration, revocation, and auditability.

Presigned URLs are one useful building block. They are not a complete file-sharing permission system.

I wrote a practical guide with the database approach, SQL, and tests:

Expiring and Revocable File Links

The guide is designed to be useful even if you do not use Filelayer. Disclosure: I created Filelayer and continue to build and maintain it.

If you want to explore the broader project, the source code is available here:

Filelayer on GitHub