Parents

The UploadFileRequest optionally takes parents. If no parents are set, then the new node is assigned the root as its parent.

Suppressing Deduplication

Amazon Drive rejects uploads that have the same SHA-256 as an existing file in the same drive. If it is desired to have multiple copies of the same file, then you should use the deduplicate suppression option.

Retrying

Uploads are not automatically retried by AmazonCloudDriveClient because the InputStream may be in a different state than the original state. To retry uploads, create a new instance of the UploadFileRequest with a new InputStream and call uploadFile() again.

Downloading a File

Files can be downloaded using the downloadFile() and downloadFileAsync() methods.

Retrying

Downloads are not automatically retried by AmazonCloudDriveClient because the OutputStream may be in a different state than the original state. To retry uploads, create a new instance of the DownloadFileRequest with a new OutputStream and call downloadFile again.

Protecting Customer Content

Amazon Drives contain personal content such as photos, videos, and documents. Download files to the internal storage directory so that this content is not available to other applications. If your application requires another application to use the downloaded file, then create a ContentProvider that will provide this data. For more details about how to share files with appropriate restrictions, see the Secure File Sharing section on the Android Developer website.

Monitoring Progress

Upload and download APIs have a special handler for monitoring progress called ProgressListener. The progress callback method happens on the background thread. If you are updating a ProgressBar or other UI element, then you must send an update from the onProgress() callback method to the main thread.

// In this example, there is a handler (mHandler) that is able to post to the// UI thread.ProgressListenerprogressListener=newProgressListener(){@OverridepublicvoidonProgress(finallongprogress,finallongmaxProgress){mHandler.post(newRunnable(){@Overridepublicvoidrun(){if(mProgressBar!=null){// The progress from the client is a long, but Android// progress bars require an int. This is usually not an// issue, but can be a problem for very large files.// The progress is rebased to Integer.MAX_VALUE to avoid// this issue.mProgressBar.setIndeterminate(false);mProgressBar.setMax(Integer.MAX_VALUE);mProgressBar.setProgress((int)(Integer.MAX_VALUE*(progress/(double)maxProgress)));}}});}};