garrettAG
garrettAG
CDCloudflare Developers
Created by garrettAG on 6/23/2023 in #workers-help
R2 signed url creation from Worker
I am attempting to create a signed url on a worker for R2 using the aws4fetch package, but the signed value being returned is an empty object. async function createSignedUploadUrl(requestPath: string) { const r2 = new AwsClient({ accessKeyId: ACCESS_KEY_ID, secretAccessKey: SECRET_ACCESS_KEY, }); const url = new URL( https://${env.BUCKET_NAME}.${env.ACCOUNT_ID}.r2.cloudflarestorage.com ); url.pathname = requestPath; console.log(url: ${url}); const signed = await r2.sign( new Request(url, { method: "PUT", }), { aws: { signQuery: true }, } ); return signed; } url value is "https://BUCKET_NAME.ACCOUNT_ID.r2.cloudflarestorage.com/icon.png" signed value is {}
6 replies