Vitali
05/01/2022, 3:43 PMErisa | Support Engineer
05/01/2022, 4:07 PMIsaac McFadyen | YYZ01
05/01/2022, 4:08 PMIsaac McFadyen | YYZ01
05/01/2022, 4:08 PMIsaac McFadyen | YYZ01
05/01/2022, 4:08 PMawait env.BINDING.get("key")
directly, I think.Erisa | Support Engineer
05/01/2022, 4:08 PMErisa | Support Engineer
05/01/2022, 4:08 PMIsaac McFadyen | YYZ01
05/01/2022, 4:08 PMIsaac McFadyen | YYZ01
05/01/2022, 4:08 PMIsaac McFadyen | YYZ01
05/01/2022, 4:09 PMErisa | Support Engineer
05/01/2022, 4:09 PMfile = await env.R2_BUCKET.get(id);
and then later js
response = new Response(await file.arrayBuffer(), {
headers: {
'cache-control': 'public, max-age=604800',
'content-type': file.httpMetadata?.contentType,
'etag': file.httpEtag,
},
});
Isaac McFadyen | YYZ01
05/01/2022, 4:09 PMErisa | Support Engineer
05/01/2022, 4:09 PMIsaac McFadyen | YYZ01
05/01/2022, 4:09 PMarrayBuffer
it buffer it in memory.James
05/01/2022, 4:09 PMR2Object.body
directly to a new Response()
since it's a readable stream, but that never actually worked for me. So in my code I do an inline await R2Object.arrayBuffer()
, which will buffer it all.Isaac McFadyen | YYZ01
05/01/2022, 4:09 PMErisa | Support Engineer
05/01/2022, 4:09 PMJames
05/01/2022, 4:10 PMIsaac McFadyen | YYZ01
05/01/2022, 4:10 PMIsaac McFadyen | YYZ01
05/01/2022, 4:10 PMErisa | Support Engineer
05/01/2022, 4:10 PMwrangler dev
with wrangler1Erisa | Support Engineer
05/01/2022, 4:11 PMJames
05/01/2022, 4:11 PMnew Response(file.body, ...)
?Erisa | Support Engineer
05/01/2022, 4:11 PMjs
response = new Response(file.body, {
headers: {
'cache-control': 'public, max-age=604800',
'content-type': file.httpMetadata?.contentType,
'etag': file.httpEtag,
},
});
James
05/01/2022, 4:11 PMErisa | Support Engineer
05/01/2022, 4:11 PMErisa | Support Engineer
05/01/2022, 4:11 PMErisa | Support Engineer
05/01/2022, 4:11 PMIsaac McFadyen | YYZ01
05/01/2022, 4:12 PMJames
05/01/2022, 4:12 PM