I manager to run the example provided by Google for uploading a file directly to your Drive via an android App. (https://github.com/googledrive/android-quickstart ) I have been reading the documentation for how to get a call-back when the photo is uploaded but I haven't found how to connect it with the creation of the object which handles everything for the upload.

My main target is to retrieve the public URL of the uploaded picture

 // Create the initial metadata - MIME type and title.
            // Note that the user will be able to change the title later.
            MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
                    .setMimeType("image/jpeg").setTitle("Android Photo.png").build();
            // Create an intent for the file chooser, and start it.
            IntentSender intentSender = Drive.DriveApi
                    .newCreateFileActivityBuilder()
                    .setInitialMetadata(metadataChangeSet)
                    .setInitialDriveContents(result.getDriveContents())
                    .build(mGoogleApiClient);
            try {
                // (???????) how I should handle the callback for the metadata here
                startIntentSenderForResult(
                        intentSender, REQUEST_CODE_CREATOR, null, 0, 0, 0);


            } catch (SendIntentException e) {
                Log.i(TAG, "Failed to launch file chooser.");
            }
1

There are 1 best solutions below

0
On

If you want to get notified when the file is created on the server, I think you will need to create file programmatically (instead of using the CreateFileActivityBuilder) and request for Completion Events. See https://developers.google.com/drive/android/completion for deatils.