payload: Can't use focal points or cropping in 2.4.0 with plugin-cloud-storage
Link to reproduction
No response
Describe the Bug
After cropping or setting the focal point and pressing save, I get this error:
FileUploadError: There was a problem while uploading the file.
at generateFileData (cms/node_modules/payload/src/uploads/generateFileData.ts:81:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at updateByID (cms/node_modules/payload/src/collections/operations/updateByID.ts:142:57)
at updateByIDHandler (cms/node_modules/payload/src/collections/requestHandlers/updateByID.ts:36:17)
Also, when setting focal point on a new upload, the image will save, but the focal point won’t be saved. Then trying to edit it, get the same error as the one above.
Here’s a video walkthrough: https://share.cleanshot.com/pbC2DvJN
To Reproduce
Here’s my cloud storage config:
payloadCloudStorage({
collections: {
'media': {
adapter: s3Adapter({
config: {
credentials: {
accessKeyId: process.env.CLOUDFLARE_ACCESS_KEY_ID,
secretAccessKey: process.env.CLOUDFLARE_SECRET_ACCESS_KEY,
},
region: 'auto',
endpoint: process.env.CLOUDFLARE_ENDPOINT,
},
bucket: process.env.CLOUDFLARE_BUCKET,
}),
},
}
}),
And here’s my media collection config:
export const Media: CollectionConfig = {
slug: 'media',
access: {
read: () => true,
},
upload: {
disableLocalStorage: true,
adminThumbnail: 'thumbnail',
imageSizes: [
{
name: 'webp',
formatOptions: {
format: 'webp',
options: {
quality: 100
}
},
withoutEnlargement: true,
},
{
name: 'webp_1280',
width: 1280,
formatOptions: {
format: 'webp',
},
withoutEnlargement: true,
},
// This is used for thumbnails in the CMS
{
height: 256,
width: 256,
position: 'center',
name: 'thumbnail',
},
],
},
Payload Version
2.4.0
Adapters and Plugins
payloadCloudstorage
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 1
- Comments: 37 (14 by maintainers)
@ssyberg yes absolutely. I’ll take look into it, along with this similar issue.
@JessChowdhury can we reopen this? I’m still having this issue on 2.8.2 even with
cloudStoragedisabled locally (also broken in production withcloudStorageenabled`@drosteluk Thanks for the cache hints. There is no CDN in my scenario, I have hooked payload directly to azure storage. But it was browser cache. The afterRead hook did the trick.
Since I’m using multiple sizes, I needed a bit different hook. I created it like this:
Thanks for fixing this @drosteluk and @denolfe 🎉
@ssyberg I have the exact same issue with payload and not being able to readjust focal points after uploading media on payload 2.8.2.
It is different the second time (when you change the focal point) because then
uploadEditswill be true when it hits this code.I think the issue might be something simple within this block, I will investigate further and get back to you.
Do you have a
serverURLdefined in your payload config? I am noticing that this also affects the fileurls.UPDATE:
Even when the URL is correct, the request gets denied access. We need to fix the authentication during the request then this should be working as expected - I’ll work on this first thing tomorrow and get back to you.
@JessChowdhury Adding
generateFileURLbreaks my frontend which is expecting relative paths like/media/filename.jpgand then prefixes the CMS domain in front of that, e.g.cms.site.com, When I addgenerateFileURL, the URLs returned by all media items are the absolute URLs from Cloudflare. I could adjust my frontend, but I’m confused now how it’s been working fine with the relative paths and letting Payload spit back the media I need (keeping the Cloudflare bucket private).@denolfe there is no logging of the root cause here. But are there any temp files on the local filesystem here when generering the new image files for new focal point?
if that is the case then maybe that is why its failing for me because the Azure Web App is running from package in read only mode.
@denolfe I’m still getting this issue when setting a focal point. I’m using a Azure Storage and not S3.
Versions:
It works fine in local dev environment (npm run dev) also running against Azure Storage Environment.
But after deploying (to Azure Web App) in production mode I get error.
In browser:
400 Bad requestResponse:{"errors":[{"message":"There was a problem while uploading the file."}]}In server side: