Metadata not being inserted - R2 Presigned URLs
hello, i've included metadata during the url presigning, but the uploaded file doesn't have custom metadata on r2 dashboard
e.g of presigned url
14 Replies
hello
You need to pass the meta data in the header as well. After you create the pre-signed URL this what you have to do:
I did add that header previously, but I get 403 http error
as soon as I comment that header, it works, but no metadata gets added
ok I tested with direct uploads with PutObjectCommands without using presigned urls, and metadata works
how do I make it work with presigned urls?
Hmm, that's interesting. I haven't tried it pre-signed URL yet. Let me try and get back to you
any updates?
I tried and running into issues. Asked for some intputs from the team
i am running into this as well
I run into the same issue months ago with the AWS SDK on AWS S3 (the product was not Cloudflare R2 but the SDK was the same I think), and after a research I thought the possible issue was about that the headers were not presigned properly. It was common at that moment, not sure if there is any workaround for now when it's necessary to use a presigned url.
any updates for this issue?
I learned that it has to do with the AWS SDK. Some of these SDKs don't work well enough to add Metadata.
Alright, so I got something working. I'll upload the code on GitHub soon, but here's what you want to do:
Replace
METADATA
with your metadata key.Here's the repo: https://github.com/harshil1712/r2-pre-signed-upload-metadata
GitHub
GitHub - harshil1712/r2-pre-signed-upload-metadata: This project de...
This project demonstrates a Cloudflare Worker that handles file uploads to R2 storage using pre-signed URLs with custom metadata. - harshil1712/r2-pre-signed-upload-metadata
this worked. thank you!