Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle externalstorage.documents in getRealPathFromURI #389

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ public void run() {
Context appCtx = ReactNativeBlobUtilImpl.RCTContext.getApplicationContext();
String t123 = String.valueOf(options.addAndroidDownloads.hasKey("storeLocal"));
String t1234 = String.valueOf(options.addAndroidDownloads.getBoolean("storeLocal"));
RNLog.w(ReactNativeBlobUtilImpl.RCTContext, t123);
RNLog.w(ReactNativeBlobUtilImpl.RCTContext, t1234);
// RNLog.w(ReactNativeBlobUtilImpl.RCTContext, t123);
// RNLog.w(ReactNativeBlobUtilImpl.RCTContext, t1234);
// use download manager instead of default HTTP implementation
if (options.addAndroidDownloads != null && options.addAndroidDownloads.hasKey("useDownloadManager")) {

Expand Down Expand Up @@ -279,7 +279,7 @@ public void run() {


if (options.addAndroidDownloads.hasKey("storeLocal") && options.addAndroidDownloads.getBoolean("storeLocal")) {
RNLog.w(ReactNativeBlobUtilImpl.RCTContext, "a");
// RNLog.w(ReactNativeBlobUtilImpl.RCTContext, "a");
String path = (String) ReactNativeBlobUtilFS.getSystemfolders(ReactNativeBlobUtilImpl.RCTContext).get("DownloadDir");
path = path + UUID.randomUUID().toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.provider.MediaStore;
import android.content.ContentUris;
import android.content.ContentResolver;
import android.os.Environment;

import com.ReactNativeBlobUtil.ReactNativeBlobUtilUtils;

Expand Down Expand Up @@ -128,6 +129,19 @@ else if ("content".equalsIgnoreCase(uri.getScheme())) {
if (isGooglePhotosUri(uri))
return uri.getLastPathSegment();

if (isExternalStorageDocument(uri)) {
final String[] split = uri.getPath().split(":");
final String type = split[0];

if ("/tree/primary".equalsIgnoreCase(type)) {
File dir = Environment.getExternalStorageDirectory();
if (dir != null) return dir + "/" + split[1];
return "";
}

// TODO handle non-primary volumes
}

return getDataColumn(context, uri, null, null);
}
// File
Expand Down