#PayloadCMS Image URL Directly from S3 Storage

1 messages · Page 1 of 1 (latest)

spring galeBOT
#

Guys, payloadcms returns as url of the image "mysite/api/media/myfile.jpg" is there way this to not go throught vercel and to return me the url in s3 storage ?

carmine etherBOT
#

Original message from @broken rover - Moved from #general message

fallen python
broken rover
#

ha thanks, this will be very cost effective solution

fallen python
#

My pleasure

carmine etherBOT
broken rover
#

in what case this is used?

For example in my frontend i dont want to fetch images from /api/media because this will make heavy request and not cost effective on vercel.

Is there another use-cases ?

I'm asking because I would not find it easy.

#

I did something similar for admin panel also:

// Media Collection
upload: {
        disableLocalStorage: true,
        // To not return images in /admin via /api -> this goes throught nextjs
        adminThumbnail: ({ doc }) => {
            return `${process.env.S3_URL}/${process.env.S3_BUCKET}/${doc.filename}`
        },

Is that good practice ?

fallen python
#

That's exactly the use-case. It also means no excess computation for media collections which are already public facing

#

For adminThumbnail it's fine

broken rover
#

Thank you man, you drive this community very hard 😄 hope paid enough

fallen python
#

My pay is having users like you make super awesome projects with Payload hahah, again it's my pleasure