How to stream R2 file inside FormData in fetch request body?
I was wondering if it’s possible to stream an R2 object to an external API using FormData instead of reading the whole blob into memory. The file size can be more than 2GB.
6 Replies
You can’t
I would imagine it’s mainly a limitation due to FormData’s boundary
Is there a way to stream the file and data without using FormData?
Put the metadata in a header or query param and then pass the body as-is
That works when you need to only stream the file. It doesn't work when you have both a file and some form fields.
Well, that’s why I said the header or query param
If you want to stream the body then that has to be the only thing in the body
How are browsers able to stream the files added to FormData? Is there some difference in the implementation of spec in Workers?