itinance / react-native-fs

Native filesystem access for react-native
MIT License
4.97k stars 986 forks source link

iOS uploader exposing upload from file method #1200

Open humaidk2 opened 1 year ago

humaidk2 commented 1 year ago

Hi,

I've recently implemented an ios app extension in some resource constrained environment and found that when you use multipart requests with ios, you end up reading the entire file into memory and append the form data to it which can be very resource intensive.

I found that URLSession method for uploading files directly from file, streams the data directly to the server, and consumes a lot less resources. I think it would be great if you could expose that method as well, in a react-native-fs way.

Also the multipart req in general could be rewritten to stream the data, and not doing

    [reqBody appendData:fileData];