Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

Can't upload non-local files with content:// URIs #381

Closed
ivankashtanov opened this issue Jun 1, 2017 · 5 comments
Closed

Can't upload non-local files with content:// URIs #381

ivankashtanov opened this issue Jun 1, 2017 · 5 comments

Comments

@ivankashtanov
Copy link

ivankashtanov commented Jun 1, 2017

Hi,
I've been trying to use this package for uploading files I pick on device using system's document picker.
It provides access to local files and Google Drive content as well. Most of GD data is not on device but picker returns content://com.google.android.apps.docs.storage/document/... URI, i.e. content:// URIs as well.
Unfortunately, using it for upload result in an error on this line that says something like can't invoke method String.toCharArray() on null object reference.

AFAIU, reading content URIs should be done using ContentResolver object (details here). Example there shows bitmap reading but it's also possible to create input stream from URI to read any type of data (details here, section "Get an InputStream").

It would be great to change content URI handling so that ContentResolver is used when needed.

@ivankashtanov
Copy link
Author

I've managed to make it work for remote GD files, will make a PR if I have time.

ivankashtanov referenced this issue in unclechau/react-native-document-picker Jun 1, 2017
@ivankashtanov
Copy link
Author

Here is my solution. It copies the way bundle-assets:// are handled, but uses ContentResolver.inputStream for stream creation.
Haven't tested all cases (only multipart body case), so didn't make a PR yet.

@akuma06
Copy link

akuma06 commented Jun 12, 2017

Even android.getContentIntent gives us a content:// uri :/. Really need this

@wkh237
Copy link
Owner

wkh237 commented Jun 14, 2017

There's a PR #374 merged for solving this issue. Please try to install the package from branch issue-374 and see if it works.

@wkh237
Copy link
Owner

wkh237 commented Jul 3, 2017

closing this issue as it's similar to #287

@wkh237 wkh237 closed this as completed Jul 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants