tonyofrancis / Fetch

The best file downloader library for Android
https://www.meta.stackoverflow.com/tags/fetch2
Apache License 2.0
1.62k stars 325 forks source link

MediaStore Uri not supported #579

Open jemshit opened 3 years ago

jemshit commented 3 years ago

Hi, i'm trying to use this library and it seems like a great work 👍

I want to download file to shared storage (Movies/myVideo.mp4). Currently Fetch supports file:///files/ and content://com.contentprovider.provider/ URIs.

If app wants to create file on shared storage

When getting URI from MediaStore, it returns something like content://media/external/video/media/148 which does not work with Fetch. This line throws FileNotFoundException: No item at content://media/external/video/media/148

Starting from Android 11, only choices seem to be (to create file on shared storage)

Imho best way to deal with File/Uri:

husam47 commented 3 years ago

Same issue am trying to update my apps to supports android 11, but facing this issue for android 10, and 11, any quick solution ???

jemshit commented 3 years ago

How i converted Uri to OutputStream.

saeedata commented 3 years ago

@jemshit Hi, I have a same issue, would you please say that how did you solve this issue? I'll be thankful if you help me

jemshit commented 3 years ago

@saeedata either download using okhttp without this library. Or use fetch to download to app private directory first, then copy to shared storage and delete temp file.

saeedata commented 3 years ago

@jemshit yeah I thought about these answers. BTW, thank you so much bro.

saeedata commented 2 years ago

I could integrate this library with Media store and sdk 30 without changing the library, Actually there are two bugs in the library, the first is in requesting to get storage permission in android 30, and the other is in creating file in Mediastore because the library seems that supports uri, however by implementing these problems in my app, I could integrate it with sdk 30. I also want to say, as I checked and reviewed the library full code, I want to raise another bug that is: if you pause a downloading file and reinstall the app, the library doesn't check the file size if it's available in path, download from the beginning.