miguelpruivo / flutter_file_picker

File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.
MIT License
1.35k stars 672 forks source link

README/pub.dev front page MUST mention that files are ALWAYS cached on Android #1606

Closed dattasid closed 1 week ago

dattasid commented 1 month ago

Action item

The documentation main page must make developers targeting Android aware that

  1. All picked files are cached in temporary storage.
  2. The app must implement cache management (display cache usage to user, clear cache based on some criteria). Otherwise they risk making users very angry.

Gap in documentation

Nowhere in file_picker documentation is it mentioned that files will be cached on Android. I just happened to notice a log statement . Then I checked the cache for the media app I am building and sure enough, I was using 1GB of cache for no good reason. I was storing multiple copies of the same files that I was using for testing.

The issue is I would have greatly annoyed users, when they found the limited space on their devices rapidly dwindling. All because my app was building a pointless copy of their entire media library.

Root Cause

In FileUtils.java , openFileStream will always create a cached copy of the file.

I can see the reason why. It works around many corner cases. Remote URI, additional permissions for accessing content URIs as files, so many issues can be easily resolved by making a quick cache of the file.

Except, without any kind of cache management, this is a dangerous thing to do. Even if the files are small, the cache might eventually become big. With media files etc, the cache will become very big very fast.

Since many developers are not even aware that this is happening, they dont even know they might need to manage the cache, or at a minimum tell the users to clear the cache if they are having space issues.

Also, the user clearing cache indiscriminately will cause problems for many apps which allow users to resume playing the same file.

I see that this has been an issue for 4+ years so I dont suppose we can have a 'dont cache' option.

Conclusion

Please make developers aware that files on Android will be cached and the app will need to account for this.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 7 days with no activity.

MichalNemec commented 1 month ago

We found out after two weeks of debugging (more functionality in app, so hard to pinpoint) and not even this helped us await FilePicker.platform.clearTemporaryFiles();

We will now try file_selector.

github-actions[bot] commented 4 weeks ago

This issue is stale because it has been open for 7 days with no activity.

github-actions[bot] commented 1 week ago

This issue was closed because it has been inactive for 14 days since being marked as stale.