Hi, I've configured S3 to be our image cloud storage. I'm getting this error message when I try to upload an image:
[12:45:18] ERROR (NoSuchKey): The specified key does not exist.
NoSuchKey: The specified key does not exist.
at deserializeAws_restXmlNoSuchKeyResponse...
This is my setup, am I missing something? We were able to make it work a while back but now as we're preparing to go live with our new CMS and set the production env, we again unable to make it work.
env:
"@payloadcms/plugin-cloud-storage": "^1.0.14",
"payload": "1.5.9",
"@aws-sdk/client-s3": "^3.272.0",
"@aws-sdk/lib-storage": "^3.272.0",
payload config code:
let cloudStorageAdapter: Adapter;
cloudStorageAdapter = s3Adapter({
config: {
forcePathStyle: false,
region: process.env.S3_REGION,
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
},
},
bucket: process.env.S3_BUCKET,
});
...
plugins: [
// Pass the plugin to Payload
cloudStorage({
collections: {
media: {
adapter: cloudStorageAdapter,
},
},
}),
....
Have you tried changing
forcePathStyle
to true?
You might also need to set
config.endpoint
to
https://s3.amazonaws.com
as seen here:
https://github.com/payloadcms/plugin-cloud-storage/blob/master/dev/src/payload.config.ts#LL31C41-L31C41Hi @denolfe .. I tried, this is my updated config:
cloudStorageAdapter = s3Adapter({
config: {
endpoint: '
https://s3.amazonaws.com',
forcePathStyle: true,
region: process.env.S3_REGION,
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
},
},
bucket: process.env.S3_BUCKET,
});
I'm now getting the following error:
(PermanentRedirect): The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
the endpoint config has no trailing "/", for some reason discord add it when I send the message
Is your S3_BUCKET value configured as just the name? It
shouldn'tinclude
s3-<region>.amazonaws.com
in it.
Yes, it includes just the name
@denolfe I still couldn't find a solution. I upgraded to the latest version of payload as well but no luck with the s3 storage
I'd do some research on that specific error. Could be something on the AWS side of things. Have you tried using the AWS CLI to do a simple read/write to see if you get any errors?
@liorix Does it work if you remove the
region
setting?
I've had this mess me up before.
@dribbens eventually it looks like it's working. on my machine I get this error by my cto and test environment is working as expected.
btw, does the forcePathStyle parameter still working or I should use the generateFileURL parameter to build the s3 full path url?
@liorix, Is this still giving you trouble?
forcePathStyle
should work, I don't know of any issues surrounding it.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.