just change the method to `PUT` and it'

just change the method to
PUT
and it'll work. You'll likely want to add
If-Unmodified-Since
to ensure write-once only. The rest is optional, though I would really encourage all of the headers here for various reasons. 🙂

const signed_url = await aws_client.sign(
        new Request(url, {
          method: "PUT",
        }),
        {
          aws: { signQuery: true, allHeaders: true },
          headers: {
            "If-Unmodified-Since": new Date(0).toUTCString(),
            "Origin": "http://localhost:3000"
            "Content-Type": "image/jpeg",
            "Content-Disposition": "attachment",
            "Cache-Control": "private, max-age=0, stale-if-error=31536000",
          },
        }
      );


r2
Was this page helpful?