To write directly to the SD Card on Android 6+ we have to use the Access Framework, but it changes the File to DocumentFile, can you add the option to pass a custom DocumentFile, or instead the outputStream from the DocumentFile?
I face the same problem. But here are few things to note:
Uri, which can be created from File, from DocumentFile. So it would be grait to replace or just add setPath(String path) with setUri(Uri uri) in BaseDownloadTask.I've tried to do it myself, but the library source code is too complex for me.
Here is how to open OutputStream from Uri:
Uri uri = ...;
ParcelFileDescriptor pfd = context.getContentResolver().openFileDescriptor(uri, "w");
FileOutputStream fileOutputStream = new FileOutputStream(pfd.getFileDescriptor());
I have no issues with SD in Api 19
I did that method in one part of my app, but the FileDescriptor closes while writing, i found other method to do the transfer:
Uri uri = ...;
OutputStream outputstream=getContentResolver().openOutputStream(uri, "rw");
Sorry for my missed this issue, this is very significant.
Did anyone manage to have a workaround while this feature is being developed? I tried creating a class that implements FileDownloadOutputStream but that only takes in a File in the Creator constructor
Sorry guys, I will handle this in the next version.
Any plan to release 1.4.2?
Sorry for delay, I tried to write code to support this feature, but it's not free time enough time for me, so all processing is intercepted.
On the 1.5.8, it will be implemented with:
.temp file mechanism to .lock file mechanism, which means we no longer using the temp file since we have no access permission to its .temp file, and we store its .lock file to the application folder and make the mapping to the target file path if the .lock file exists the file is not completed downloading, so we can feel free to pre-allocate for the target file with write data to the target file directly..temp file migration: I will try to migrate the .temp file, but if there isn't permission to access the old .temp file, it will be discarded directly.Above is the imagine plan, any advice for this feature is open... please comment and let me know.
Please do this. :+1:
@Jacksgong When can we expect this ? Thank you for amazing library
This issue has been solved on okdownload.
Most helpful comment
I face the same problem. But here are few things to note:
Uri, which can be created fromFile, fromDocumentFile. So it would be grait to replace or just addsetPath(String path)withsetUri(Uri uri)inBaseDownloadTask.I've tried to do it myself, but the library source code is too complex for me.
Here is how to open
OutputStreamfromUri: