Hi, I'm using the s3 payload plugin to integrate digitalocean spaces to my payload cms and I am also using next-payload to run my site through vercel. When I upload an image to my media collection, how can I access that image to use for my site? Also, do I have to change my staticUrl and staticDr since im using an s3? Any help is appreciated. Thanks.
I was able to get DO Spaces working in my dev environment with a "normal" Payload setup. I got the Next+Payload example working as well, but I am unable to see the images. It detects the four images that I save in to Spaces, but there is no actual image ... just image title, size, etc.
You will need to provide the proper URL to the file on DO Spaces.
The way I typically handle this is by setting the URL with an
afterRead
hook on my collection for the file in DO Spaces. my hook looks like this:
hooks: {
afterRead: [
async ({ doc }) => {
doc.url = process.env.CONTENT_URL + '/images/' + doc.filename;
},
]
},
for the
doc.url
, set it to whatever the link to your file would be. You can find this from the DO Spaces dashboard.
Then, when I am adding in an image in Next, I just set the url accordingly, setting the
src
to they value returned from my API call.
Thanks!
Star
Discord
online
Get dedicated engineering support directly from the Payload team..