© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•3y ago•
1 reply
Julian

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);
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Get Content-Length
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago
Customize Content-Length header
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3mo ago
Missing "Content-Length" from worker response
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago
Reading in local file content?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago