filestack / filestack-android

Official Android SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
https://www.filestack.com
Apache License 2.0
156 stars 90 forks source link

Upload from Google Drive has no key #105

Closed OliverMannhart closed 7 years ago

OliverMannhart commented 8 years ago

Hey there

I have an issue if I upload a file from google drive. In the resulting FPFile the key is null (unlike if uploaded from the gallery).

But I need this key to know were in the amazon s3 storage the file was uploaded.

Is this a bug or is it supposed to work like this?

thanks

ghost commented 8 years ago

Do you define any store options? Please note, that setting ‘path’ store option disables generating unique key value for Filepicker file.

If that's not your case, please share the snippet of code where you define the Filestack activity.

OliverMannhart commented 8 years ago

Thanks for the response. I don't think I set any store option. Here the snippet:

        Filepicker.setKey("...");
        Filepicker.setAppName("Some Name");
        String[] services = {"GALLERY","CAMERA","GOOGLE_DRIVE"};
        Intent intent = new Intent()
                .setAction(Filepicker.ACTION_EXPORT_FILE)
                .setClass(context, Filepicker.class)
                .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
                .putExtra("services", services)
                .putExtra("multiple", true);

        frag.startActivityForResult(intent, Filepicker.REQUEST_CODE_EXPORT_FILE);
ghost commented 7 years ago

Sorry for the late response.

Exporting feature (ACTION_EXPORT_FILE action) is intended for the local files to be exported to the following cloud services: Cloud Drive, Dropbox, Box, Instagram, Flickr, Picasa, Evernote and Skydrive. Looking at you code snippet you specify unsupported services (Gallery, Camera and Google Drive) and don't specify any local file URI.

In order to get a file from the Google Drive and export is somewhere else use REQUEST_CODE_GETFILE action.

OliverMannhart commented 7 years ago

Hey there, no problem.

I am not trying to get a file from google drive. I just want the file uploaded to amazon. This works with Gallery and Camera but not with google drive. Does the filestack sdk not support this?

The use case would be something like that: 1.) Start the filepicker intent 2.) User chooses a file (maybe from google drive, dropbox, flickr...) 3.) User clicks upload in the filepicker view. 4.) File will be uploaded by the filepicker sdk.

In my mind, the app using the filepicker sdk should't have to export the file.

ghost commented 7 years ago

REQUEST_CODE_EXPORT_FILE action provides a way of uploading the local files to some specified cloud services. You can't use this action to upload a file from any cloud service (including Google Drive) unless you download it to your device first.

I don't see how the code you provided above is working for you as that's not the way REQUEST_CODE_EXPORT_FILE should be used. Path of a (local) file to be uploaded should be specified in setData(..) call (as described in docs), while 'services' extra should be used to specify destination services where the file should be uploaded.

You can upload your file to the S3 using REQUEST_CODE_GETFILE action with the store options specified. Please note you should configure your S3 access through your Developer Portal first.

OliverMannhart commented 7 years ago

Hey thank you very much. Your last post was very helfpull.

If I set the store option “location” to S3 and use REQUEST_CODE_GETFILE everything works as expected and there are no null-keys.

Strangely, it does also work if I use REQUEST_CODE_EXPORT_FILE and ACTION_EXPORT_FILE (which should not be done, as you pointed out). Furthermore, Camera and Gallery always generate a key, even with no location set.

But thats just what I observed. Not sure if thats a problem at all.

Thank you again, for explaining it to me. I really appreciate it.

ghost commented 7 years ago

No problem. Happy it worked for you.