S3 cloud storage overwrites filesize to zero when editing an image
Link to reproduction
No response
Environment Info
Payload: 3.0.0-beta.100
Next js: 15.0.0-canary.137
Describe the Bug
When using @payloadcms/storage-s3 as media storage I've noticed that when I edit an existing file, the filesize database column gets overwritten to 0. This then shows in the frontend to as if the image has no bytes.
Reproduction Steps
- Configure an upload collection with any text field (e.g.: name)
- Configure @payloadcms/storage-s3 as media storage for that collection
- Upload an image
- Edit the text field (e.g.: name)
- filesize will get written again to 0, removing valuable information about the file
Adapters and Plugins
@payloadcms/storage-s3
This issue has been marked as stale due to lack of activity.
To keep this issue open, please indicate that it is still relevant in a comment below.
Still happening
has anyone got a resolution to this? some more detail from my perspective.. this does not happen for local storage. it starts happening when I switch to the s3 adaptor ( @payloadcms/storage-s3 ). I'm using @payloadcms/storage-s3 3.11.0
when I upload an image initially everything is fine.
the api looks like this... note the file size and mimeType
{
"id": 2,
"alt": null,
"prefix": "custom-images",
"updatedAt": "2025-01-08T13:23:15.097Z",
"createdAt": "2025-01-08T13:23:15.097Z",
"url": "/api/images/file/iStock-1305515723.jpg",
"thumbnailURL": "/api/images/file/iStock-1305515723-300x200.jpg",
"filename": "iStock-1305515723.jpg",
"mimeType": "image/jpeg",
"filesize": 137620,
"width": 2121,
"height": 1414,
"focalX": 50,
"focalY": 50,
"sizes": {
"thumbnail": {
"url": "/api/images/file/iStock-1305515723-300x200.jpg",
"width": 300,
"height": 200,
"mimeType": "image/jpeg",
"filesize": 5353,
"filename": "iStock-1305515723-300x200.jpg"
},
"square": {
"url": "/api/images/file/iStock-1305515723-500x500.jpg",
"width": 500,
"height": 500,
"mimeType": "image/jpeg",
"filesize": 22856,
"filename": "iStock-1305515723-500x500.jpg"
},
"small": {
"url": "/api/images/file/iStock-1305515723-600x400.jpg",
"width": 600,
"height": 400,
"mimeType": "image/jpeg",
"filesize": 16690,
"filename": "iStock-1305515723-600x400.jpg"
},
"medium": {
"url": "/api/images/file/iStock-1305515723-900x600.jpg",
"width": 900,
"height": 600,
"mimeType": "image/jpeg",
"filesize": 32947,
"filename": "iStock-1305515723-900x600.jpg"
},
"large": {
"url": "/api/images/file/iStock-1305515723-1400x933.jpg",
"width": 1400,
"height": 933,
"mimeType": "image/jpeg",
"filesize": 69422,
"filename": "iStock-1305515723-1400x933.jpg"
},
"xlarge": {
"url": "/api/images/file/iStock-1305515723-1920x1280.jpg",
"width": 1920,
"height": 1280,
"mimeType": "image/jpeg",
"filesize": 116051,
"filename": "iStock-1305515723-1920x1280.jpg"
}
}
}
if I now edit the Alt text the UI shows the following..
the API shows similar issues in the main metadata.
{
"id": 2,
"alt": "alt",
"prefix": "custom-images",
"updatedAt": "2025-01-08T13:25:44.496Z",
"createdAt": "2025-01-08T13:23:15.097Z",
"url": "/api/images/file/iStock-1305515723.jpg",
"thumbnailURL": "/api/images/file/iStock-1305515723-300x200.jpg",
"filename": "iStock-1305515723.jpg",
"mimeType": "text/html",
"filesize": 2607,
"width": 2121,
"height": 1414,
"focalX": 50,
"focalY": 50,
"sizes": {
"thumbnail": {
"url": "/api/images/file/iStock-1305515723-300x200.jpg",
"width": 300,
"height": 200,
"mimeType": "image/jpeg",
"filesize": 5353,
"filename": "iStock-1305515723-300x200.jpg"
},
"square": {
"url": "/api/images/file/iStock-1305515723-500x500.jpg",
"width": 500,
"height": 500,
"mimeType": "image/jpeg",
"filesize": 22856,
"filename": "iStock-1305515723-500x500.jpg"
},
"small": {
"url": "/api/images/file/iStock-1305515723-600x400.jpg",
"width": 600,
"height": 400,
"mimeType": "image/jpeg",
"filesize": 16690,
"filename": "iStock-1305515723-600x400.jpg"
},
"medium": {
"url": "/api/images/file/iStock-1305515723-900x600.jpg",
"width": 900,
"height": 600,
"mimeType": "image/jpeg",
"filesize": 32947,
"filename": "iStock-1305515723-900x600.jpg"
},
"large": {
"url": "/api/images/file/iStock-1305515723-1400x933.jpg",
"width": 1400,
"height": 933,
"mimeType": "image/jpeg",
"filesize": 69422,
"filename": "iStock-1305515723-1400x933.jpg"
},
"xlarge": {
"url": "/api/images/file/iStock-1305515723-1920x1280.jpg",
"width": 1920,
"height": 1280,
"mimeType": "image/jpeg",
"filesize": 116051,
"filename": "iStock-1305515723-1920x1280.jpg"
}
}
}