Search code examples
androidgoogle-drive-apigoogle-drive-android-api

Making sure a Google Drive Android API upload is stored in the server before telling the user that a file has been uploaded successfully


I am using the Google Drive Android API to provide an automatic-upload to Google Drive for user files. I followed the sample as for creating and providing contents of the file.

The last call:

final DriveFolder.DriveFileResult fileResult = folder.createFile(client, originalMetadata, contents).await();

that I think is supposed to commit the creation of the new file quickly returns, but if I immediately disconnect the device and access Google Drive on the web, I see that the file has not been actually stored in the server. It is only stored on the device, waiting for sync later.

(Obviously if I reconnect and wait for a while, the uploaded file appears on Google Drive on the web.)

My app only knows that the file has been committed and shows "Google Drive Upload was successful" but actually it is not yet stored on the server. It is misleading for the user.

With Dropbox API when it says committed, it has been really stored on the server. How can I get the same sureness with Google Drive API?


Solution

  • I think what you are looking for is completion events? https://developers.google.com/drive/android/completion