Files correctly uploaded to S3 but URL still pointing to localhost

default discord avatar
nicolaslair
6 months ago

I have configured the cloud storage plugin with S3, so files are uploaded to S3 - but the S3 URL is not used to download the files - I can't seem to find any information on why this is happening.



This is the payload config:



plugins: [ cloudStorage({ collections: { 'notes': { adapter: s3Adapter({ config: { 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 am using AWS S3 not the endpoint should not provided...


In the 'Notes' collection - the disableLocalStorage boolean is set to true:



slug: 'notes', upload: { disableLocalStorage: true },

The url of the uploaded file is still "

http://localhost:3000/notes/43_s_rockbass.mp3

" but instead it should point to the corresponding S3 bucket - the file is uploaded on S3 - the problem is just the URL.



I guess I am missing a config in the collection?



Thanks in advance, Nico



Ok I found the answer, it's quite obvious, the server stills acts as a proxy in order to provide access control - "all uploads will still be reached from the default /collectionSlug/staticURL/filename path. This plugin will "pass through" all files that are hosted on your third-party cloud service—with the added benefit of keeping your existing access control in place." -

https://github.com/payloadcms/plugin-cloud-storage/tree/master#payload-access-control
    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!

    Star

    Connect with the Payload Community on Discord

    Discord

    online

    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.