If the download is going through a Worker, you can decompress it on the fly.
If the download is going through a Worker, you can decompress it on the fly.
Content-Length header, but this requires you to know the size that the user will upload.If-Unmodified-Since header so you don't allow infinite reuploads of the same object.If-Unmodified-Since header is important too, in case R2 adds S3 Versioning support and @Anay - ping in replies enables it without thinking about this edge case allHeaders: true so it'll sign all headers, even the "non-standard" ones like User-AgentCookie headerContent-Disposition to enforce Content-Disposition: attachment. And yeah, I'd sign User-Agent if it's static for your application.Content-Type: image/jpegContent-Disposition and Cache-Control are totally personal preference and depends on the context of what you do with these images. And yeah User-Agent is optional. cc @Anay - ping in repliesContent-Disposition: attachment will prevent browsers from rendering the image inlineContent-LengthIf-Unmodified-SinceIf-Unmodified-Sinceuser-agentallHeaders: trueUser-AgentUser-AgentUser-AgentCookieContent-DispositionContent-DispositionContent-Disposition: attachmentContent-Disposition: attachmentContent-Type: image/jpegconst signed = await r2.sign(
new Request(url, {
method: "PUT",
}),
{
aws: { signQuery: true },
headers: {
"If-Unmodified-Since": "Tue, 28 Sep 2021 16:00:00 GMT",
"Content-Length" "1337",
"User-Agent": "I am legit 1.2.3.4"
},
}
);const signed = await r2.sign(
new Request(url, {
method: "PUT",
}),
{
aws: { signQuery: true },
headers: {
"If-Unmodified-Since": new Date().toUTCString(),
"Content-Length": "1337",
"Content-Type": "image/jpeg",
"Content-Disposition": "attachment",
"Cache-Control": "private, immutable, max-age=31536000",
"User-Agent": "myapp ver 1337"
},
}
);