When I put the presigned URL into a browser, I get a 403 Fobidden error. I added CORS using this via postman successfully:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
<AllowedOrigin>*</AllowedOrigin>
</CORSRule>
</CORSConfiguration>
And I created the presigned URL in a worker using this (the GUID is the name of my file):
app.get('/api/portal/', async c => {
const request = new Request(`https://<MY_BUCKET>.<MY_ID>.r2.cloudflarestorage.com/29e6eb60c9e04ad79c3978ebac7e6318`, {
method: 'PUT'
});
const presigned = await r2.sign(request, { aws: { signQuery: true } })
return c.json(presigned.url);
});
And I got this URL back:
https://<MY_BUCKET>.<MY_ID>.r2.cloudflarestorage.com/29e6eb60c9e04ad79c3978ebac7e6318?X-Amz-Date=20221209T190829Z&X-Amz-Expires=86400&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=6804aaf42ebc801a6ab4d57cf6655d47%2F20221209%2Fauto%2Fs3%2Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=7dc0b99dae1ca18b92f30c093c5012a8205f2366ca152ea9065273a69290f948
Any ideas on how to troubleshoot? Thanks