Julian
Julian
CDCloudflare Developers
Created by Julian on 1/21/2024 in #workers-help
Change Content-Length for file downloads
Hello! I am trying to change the Content-Length header, as I will use Cloudflare Workers to download files from a R2 bucket. I tried by changing the header manually, but it doesnt make a change. Then I read that it was not possible to change that header, and that the only way to do so is by using Streams. Now, my question is how should I do that? I tried to do it (see the code below), however it does not work. Any advice is very much appreciated!
firmwareBin = await env.R2.get(decodeURI(key));
let { readable, writable } = new FixedLengthStream(175104);
firmwareBin.body.pipeTo(writable);
return new Response(readable, firmwareBin);
firmwareBin = await env.R2.get(decodeURI(key));
let { readable, writable } = new FixedLengthStream(175104);
firmwareBin.body.pipeTo(writable);
return new Response(readable, firmwareBin);
2 replies
CDCloudflare Developers
Created by Julian on 1/13/2024 in #workers-help
Download BIN files (R2 Binding)
Hello! I need to download files that are stored in R2 using CF Workers as a middleman (for auth). Whats the best way to download files from R2 using Workers as the middleman? Files are < 10MiB
1 replies