#Seeking alternative methods for memory-efficient file uploads in Remix when using cloudflare workers

1 messages · Page 1 of 1 (latest)

heady torrent
#

Hello everyone, I am currently working on a project that requires file uploads in Cloudflare Workers to save them in storage. However, I am running into memory issues due to the 128MB memory limit imposed by Cloudflare Workers when using FormData for file upload. Therefore, I am seeking suggestions for alternative ways to upload files that can stream them directly to the put(...) method without buffering them into memory (i.e. not using FormData in the action function). Could anyone please share any solutions or recommendations that can help me avoid using FormData and make file uploads more memory-efficient?

buoyant scroll
#

What is the destination of the uploaded files? If it's R2 or another S3-compatible store, you could create a signed upload URL and upload the file there before submitting your form.

You're not out of luck, though. Workers support streams, documented here: https://developers.cloudflare.com/workers/learning/using-streams

Minimizing buffering is especially important for processing or transforming response bodies larger than the Worker’s memory limit. For these cases, streaming is the only implementation strategy.

I don't know if it will help with large Request bodies, though. But streams are the answer.

The Streams API is a web standard API that allows JavaScript to programmatically access and process streams of data.