diachedelic / capacitor-blob-writer

Capacitor plugin to write binary data to the filesystem
MIT License
132 stars 17 forks source link

Support for larger files #61

Closed crabbydavis closed 1 year ago

crabbydavis commented 1 year ago

First, thanks for the plugin! I'm using this to download and then write a sqlite DB to memory. My initial DB size is 320MB and the plugin isn't able to write a file that size (at least on iOS on an iPhone 12 mini). The largest file I've been able to write so far is 270MB. The plugin was able to write the 320MB file on my laptop on the iOS simulator.

The plugin tries to use the fallback mode, but that also fails. It ends up creating the file but doesn't write any data into it.

The error I get is for the 320MB file is, "WebKit encountered an internal error."

Thanks for taking a look at this!

Screenshot 2023-05-04 at 9 05 11 AM

diachedelic commented 1 year ago

Duplicate of #22. Do you have time to implement the append feature (#11), a prerequisite for what you're asking?

Miguelmcanabal commented 1 year ago

Any news on this? Im facing the same issue.

crabbydavis commented 1 year ago

@Miguelmcanabal I ended up just using the @capacitor/filesystem plugin. There's an appendFile method so that you can write the file in chunks. If you fetch your file as an array buffer, you can loop through it, grab slices, and write those slices using appendFile. I don't have timings to provide, but it writes quickly.

AgustinBaffo commented 1 month ago

I was able to wrote huge files (>5GB) using capacitor-file-chunk package. They implemented the append feature on the top of this repo:

This plugin builds on the original concept and code of the Capacitor Blob Writer plugin by providing the ability to read and write files in chunks, offering improved performance compared to the Capacitor Filesystem plugin. It enables direct communication and exchange of binary data with a localhost web server, eliminating the need for base64 conversion.