fix: S3 upload silent skip when select projects out mimeType/filename#17010
fix: S3 upload silent skip when select projects out mimeType/filename#17010deepshekhardas wants to merge 1 commit into
Conversation
When a POST request uses ?select[…] to project mimeType/filename out of the response doc, the cloud-storage plugin silently skips uploading to S3. Fix by falling back to req.file properties when data.filename/data.mimeType are undefined due to select projection. Also handle sizes fallback using payloadUploadSizes when data.sizes is missing. Closes payloadcms#16670
|
Pull Request titles must follow the Conventional Commits specification and have valid scopes. The subject "S3 upload silent skip when select projects out mimeType/filename" found in the pull request title "fix: S3 upload silent skip when select projects out mimeType/filename" |
| if (data?.sizes) { | ||
| Object.entries(data.sizes).forEach(([key, resizedFileData]) => { | ||
| if (payloadUploadSizes?.[key] && resizedFileData.mimeType) { | ||
| const sizes = data?.sizes ?? payloadUploadSizes |
There was a problem hiding this comment.
Nice fix for the main file case. I think there may still be a gap for resized images when sizes is also projected out because req.payloadUploadSizes only has the resized buffers, while the resized file metadata still comes from data.sizes. So with this fallback, resizedFileData can be a Buffer, which means resizedFileData?.mimeType is undefined and the resized variants still won’t be uploaded.
Could you, please, add a regression test for an image upload with configured sizes where the selected doc omits sizes along with filename / mimeType?
When a POST request uses ?select[...]\ to project mimeType/filename out of the response doc, the cloud-storage plugin silently skips uploading to S3.
Fix by falling back to req.file properties when data.filename/data.mimeType are undefined due to select projection. Also handle sizes fallback using payloadUploadSizes when data.sizes is missing.
Closes #16670