We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Payload and its cloud storage adapters create URLs for uploaded media files. Filenames are stored in UTF-8 but they are never encoded in the URLs:
const generateURL = ({ collectionSlug, config, filename }: GenerateURLArgs) => { if (filename) { return `${config.serverURL || ''}${config.routes.api || ''}/${collectionSlug}/file/${filename}` } return undefined }
https://github.com/payloadcms/payload/blob/main/packages/payload/src/uploads/getBaseFields.ts#L15
This code should be changed to:
const generateURL = ({ collectionSlug, config, filename }: GenerateURLArgs) => { if (filename) { return `${config.serverURL || ''}${config.routes.api || ''}/${collectionSlug}/file/${encodeURIComponent(filename)}` } return undefined }
We use encodeURIComponent() in our own GridFS plugin and this works fine. We detected this error while reviewing the Payload 3.x code changes.
https://github.com/cbratschi/payload
Upload file with spaces, the spaces are not encoded as %20 in the URL.
area: core, plugin: cloud-storage
Binaries: Node: 22.9.0 npm: 10.8.3 Yarn: 1.22.22 pnpm: N/A Relevant Packages: payload: 3.2.2 Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:05:23 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6031 Available memory (MB): 65536 Available CPU cores: 16
The text was updated successfully, but these errors were encountered:
1446fe4
🚀 This is included in version v3.9.0
Sorry, something went wrong.
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.
PatrikKozak
Successfully merging a pull request may close this issue.
Describe the Bug
Payload and its cloud storage adapters create URLs for uploaded media files. Filenames are stored in UTF-8 but they are never encoded in the URLs:
https://github.com/payloadcms/payload/blob/main/packages/payload/src/uploads/getBaseFields.ts#L15
This code should be changed to:
We use encodeURIComponent() in our own GridFS plugin and this works fine. We detected this error while reviewing the Payload 3.x code changes.
Link to the code that reproduces this issue
https://github.com/cbratschi/payload
Reproduction Steps
Upload file with spaces, the spaces are not encoded as %20 in the URL.
Which area(s) are affected? (Select all that apply)
area: core, plugin: cloud-storage
Environment Info
The text was updated successfully, but these errors were encountered: