incrediblezayed / file_saver

A simple flutter plugin for saving files in all platforms
https://pub.dev/packages/file_saver
BSD 3-Clause "New" or "Revised" License
75 stars 92 forks source link

[proposition] memory issue, use file.copy instead of converting to byte list and back #73

Closed Silfalion closed 8 months ago

Silfalion commented 10 months ago

Hi there!

I'd like to make a proposition for the saveFile when providing a file to save, maybe I didn't understand the use case but here is an example issue:

When dealing with large files in cache in the case of a video editing app for example, some media files may find themselves in the temporary directory or not a desired location, so they need to be moved to a more definitive place through this package.

However, and it's what I encountered, saving very large files will cause the app to crash since the file is converted to a byte list, so into the device memory, then to the desired location.

My proposition is to use file.save provided natively by Dart, instead of doing the conversion to byte list.

I've had to debug an app that suffered from this issue and the behavior monitored through memory device tools was identical for all files used.

I can make a PR if this is desirable.

incrediblezayed commented 10 months ago

Hey, My hands are full right now, please create a PR, I'll merge it and release. Thanks a lot for a suggestion I was already thinking about this because there's already an issue open for app crashing while saving the large file. Thank You so much

Silfalion commented 10 months ago

My pleasure, and sounds good, will create one in the next few days then:)

incrediblezayed commented 10 months ago

Yeah thanks alot man @Silfalion

incrediblezayed commented 8 months ago

Merged your PR