dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Streaming File Uploads

Open ealmloff opened this issue 2 years ago • 1 comments

Specific Demand

The current FileEngine exposes two ways to read a file: Reading the file to a string or reading the file to a byte array. Both of these methods perform poorly with large files. In addition to poor performance, you cannot provide updates to the user based on file upload progress.

Implement Suggestion

We should expose a third API that returns the size of the file (depending on the platform) and a stream with the file data

Related to https://github.com/DioxusLabs/dioxus/pull/1181

ealmloff avatar Aug 09 '23 18:08 ealmloff

Reminder on file size visibility: https://github.com/DioxusLabs/dioxus/pull/2323

And for the stream part, in my own web only project with file uploads, I use: web_file: web_sys::File and with https://github.com/MattiasBuelens/wasm-streams :

    let mut stream = ReadableStream::from_raw(web_file.stream());
    let reader = stream.get_byob_reader();

rogusdev avatar Aug 22 '24 14:08 rogusdev