Is streaming to an R2 file possible?

I have an audio stream that continuously yields audio buffers to a ReadableStream. My goal is to take these buffers and upload them to Cloudflare R2, but Iā€™m unsure of the best approach to achieve this. Is it possible to stream upload to an R2 file without knowing the size in advance? Thank you in advance šŸ™
7 Replies
bapwsta
bapwstaOPā€¢2mo ago
Got it. Any recommended workaround? I'm going to be generating huge buffers that go over the worker's memory limit.
Erisa
Erisaā€¢2mo ago
multipart with chunks that fit within the memory? worker reads e.g. 50mb from stream, uploads it as multipart, repeats until it reaches the end of the stream and then finalises the multipart upload
bapwsta
bapwstaOPā€¢2mo ago
Good idea, how to handle the finalization though? Would this not require having to download all of the buffers at once before adding them together, going over alloted memory?
Erisa
Erisaā€¢2mo ago
not with multipart, you can upload them separately
bapwsta
bapwstaOPā€¢2mo ago
yeah think I'm going to do that then use an AWS lambda function to stitch them all together thanks for the help
Erisa
Erisaā€¢2mo ago
i dont know exactly what the lamba is required for but yeah sure
bapwsta
bapwstaOPā€¢5w ago
how else than with a service with higher memory limit would I be able to merge the separately uploaded files?
Want results from more Discord servers?
Add your server