Skip to content

feat(storage-s3): dynamic presigned URL downloads #12706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 9, 2025
Merged

Conversation

r1tsuu
Copy link
Member

@r1tsuu r1tsuu commented Jun 6, 2025

Previously, if you enabled presigned URL downloads for a collection, all the files would use them. However, it might be possible that you want to use presigned URLs only for specific files (like videos), this PR allows you to pass shouldUseSignedURL to control that behavior dynamically.

s3Storage({
  collections: {
    media: {
      signedDownloads: {
        shouldUseSignedURL: ({ collection, filename, req }) => {
          return req.headers.get('X-Disable-Signed-URL') !== 'false'
        },
      },
    },
  },
})

Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, I think we just need to mention it in the s3 adapter docs before we merge.

@DanRibbens
Copy link
Contributor

In the exampe in the docs I would write up an extension based example. I'm thinking shouldUseSignedURL: (({ filename }) => (filename.endsWith('.mp4')) or something like that.

@r1tsuu r1tsuu requested a review from DanRibbens June 6, 2025 14:47
Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because shouldUseSignedURL is already inside signedDownload I wonder if we shouldn't just call it condition?

Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The consensus on our team is that this naming makes sense. 👍

@r1tsuu r1tsuu enabled auto-merge (squash) June 9, 2025 18:28
@r1tsuu r1tsuu merged commit 865a9cd into main Jun 9, 2025
151 of 153 checks passed
@r1tsuu r1tsuu deleted the feat/dynamic-signed-url branch June 9, 2025 19:03
elliott-w pushed a commit to elliott-w/payload that referenced this pull request Jun 12, 2025
Previously, if you enabled presigned URL downloads for a collection, all
the files would use them. However, it might be possible that you want to
use presigned URLs only for specific files (like videos), this PR allows
you to pass `shouldUseSignedURL` to control that behavior dynamically.
```ts
s3Storage({
  collections: {
    media: {
      signedDownloads: {
        shouldUseSignedURL: ({ collection, filename, req }) => {
          return req.headers.get('X-Disable-Signed-URL') !== 'false'
        },
      },
    },
  },
})
```
Copy link
Contributor

🚀 This is included in version v3.43.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants