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 šŸ™
6 Replies
bapwsta
bapwstaā€¢18h ago
Got it. Any recommended workaround? I'm going to be generating huge buffers that go over the worker's memory limit.
Erisa
Erisaā€¢17h 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
bapwstaā€¢16h 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ā€¢13h ago
not with multipart, you can upload them separately
bapwsta
bapwstaā€¢11h 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ā€¢6h ago
i dont know exactly what the lamba is required for but yeah sure
Want results from more Discord servers?
Add your server