sidlatau / flutter_document_picker

Allows user pick a document. Picked document is copied to app temporary directory. Optionally allows pick document with specific extension only.
Apache License 2.0
41 stars 29 forks source link

Potential Issue with copying Large files to temp directory #9

Closed ThinkDigitalSoftware closed 6 years ago

ThinkDigitalSoftware commented 6 years ago

Large Files that are copied to temp directory may fill up storage since they're being duplicated. Also, it may not be preferable to copy the files to the temp directory at all times, for example in cases where:

Long story short, can the copying to temp directory be made an optional flag that defaults to true?

sidlatau commented 6 years ago

Reason behind copying to temp directory is that in this case there is no need to handle Android permissions - no permission is required when reading/writing file from app temp dir. Additionally in iOS this copying is performed automatically. Also it could be problematic to get path to file otherwise - file could be in Google Drive or iCloud - what kind of paths to return to Flutter/Dart side in these cases? For these reasons in this plugin I have chosen to copy files to temp dir in all cases. I agree that it is not optimal but it handles most common cases. I am not planning to change this functionality but pull requests are welcome!

ThinkDigitalSoftware commented 6 years ago

For cloud cases, it can be copied, but leave the other ones optional. I'm having the issue where my files are being overwritten because they have the same name. (mmssms.db)even though I'm opening it from different directories, and I have no way of differentiating them, nor accessing anything other than the latest file. It's only a slight inconvenience now, but I do forsee the lack of the option to be a bigger problem for others.

I'd love to submit a pull request, but it would take me too far off my current focus to figure out how to adjust this.

Thank you for your excellent work so far. This is the next plugin I've found to get the job done!

DamonChen117 commented 3 years ago

Don’t copy the document if you can avoid it. From https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller