Skip to content

Pre-signed URLs

storage pre-signed URLs temporary access secure download presigned

Pre-signed URLs provide temporary, tokenless access to a file. They are useful when you need to share a file with a system or user that doesn’t have an authentication token, such as an email link, an external service, or a public-facing page that shouldn’t require login.

  1. An authenticated user requests a pre-signed URL for a file
  2. Storage checks the user’s permission to access the file (via Hasura)
  3. If allowed, a time-limited URL is returned
  4. Anyone with that URL can download the file — no authentication headers needed
  5. The URL expires after the configured duration
const { body } = await nhost.storage.getFilePresignedURL(fileId)
// body.url contains the temporary download URL
// body.expiration contains the expiration time in seconds

Pre-signed URL expiration is configured per bucket via the download_expiration field (in seconds):

Bucket settingDefault
download_expiration30 seconds
presigned_urls_enabledtrue

To change the expiration for a bucket:

mutation UpdateBucketExpiration {
updateBucket(
pk_columns: { id: "documents" }
_set: { downloadExpiration: 3600, presignedUrlsEnabled: true }
) {
id
downloadExpiration
}
}

Good use cases:

  • Sharing files via email or messaging (recipient doesn’t need to log in)
  • Serving files to external systems (webhooks, third-party integrations)
  • One-time download links

Avoid when:

  • The user is already authenticated (use direct file access instead)
  • You need long-lived URLs (pre-signed URLs expire)
  • You need CDN caching efficiency (each pre-signed URL is unique, reducing cache hit rate — see CDN)