Cloud Storage Integrator 2016 Linux Edition
Cloud Storage Integrator 2016 Linux Edition
Questions / Feedback?

DownloadFile Method

Downloads, and optionally converts, the currently selected file.

Syntax

 int DownloadFile(char* lpszmimeType);

Remarks

This method downloads the currently selected file. Select a file by calling either ListResources or GetResourceInfo and then setting ResourceIndex, or simply by setting ResourceId.

If MimeType is "", the file will be downloaded as-is. Files in one of the Google formats can be converted by setting MimeType to one of the MIME types in the table below.

If LocalFile is set the file will be saved to the specified location. If LocalFile is not set the file data will be held by ResourceData.

Google FormatDownload Format MIME Type
Google Docs HTML text/html
Plain text text/plain
Rich text application/rtf
Open Office document application/vnd.oasis.opendocument.text
PDF application/pdf
MS Word application/vnd.openxmlformats-officedocument.wordprocessingml.document
Google Sheets MS Excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Open Office sheet application/x-vnd.oasis.opendocument.spreadsheet
PDF application/pdf
CSV (first sheet only) text/csv
Google Drawing JPEG image/jpeg
PNG image/png
SVG image/svg+xml
PDF image/pdf
Google Slides MS Powerpoint application/vnd.openxmlformats-officedocument.presentationml.presentation
PDF application/pdf
Plain text text/plain
Google App Scripts JSON application/vnd.google-apps.script+json

Downloading an Encrypted File

To decrypt an encrypted file set EncryptionAlgorithm and EncryptionPassword before calling this method.


googledrive.ResourceIndex = 0;
googledrive.LocalFile = "../MyFile.zip";
googledrive.DownloadFile("");

Resuming Downloads

The class also supports resuming failed downloads by using the StartByte property. If the download was interrupted, set StartByte to the appropriate offset before calling this method to resume the download.


googledrive.ResourceIndex = 0;
googledrive.LocalFile = downloadFile;
googledrive.DownloadFile("");

//The transfer is interrupted and DownloadFile() above fails. Later, resume the download:

//Get the size of the partially download file
googledrive.StartByte = new FileInfo(downloadFile).Length; 
googledrive.LocalFile = downloadFile;
googledrive.DownloadFile("");

Resuming Encrypted File Downloads

Resuming encrypted file downloads is only supported when LocalFile was set in the initial download attempt. When beginning an encrypted download if LocalFile is set the class will create a temporary file in TempPath to hold the encrypted data until it is complete.

If the download is interrupted DownloadTempFile will be populated with the temporary file holding the partial data. When resuming, DownloadTempFile must be populated along with StartByte to allow the remainder of the encrypted data to be downloaded. Once the encrypted data is downloaded it will be decrypted and written to LocalFile.

googledrive.ResourceIndex = 0;
googledrive.LocalFile = downloadFile;
googledrive.EncryptionPassword = "password";
googledrive.DownloadFile("");

//The transfer is interrupted and DownloadFile() above fails. Later, resume the download:

//Get the size of the partially download temp file
googledrive.StartByte = new FileInfo(googledrive.Config("DownloadTempFile")).Length; 
googledrive.LocalFile = downloadFile;
googledrive.EncryptionPassword = "password";
googledrive.DownloadFile("");

 
 
Copyright (c) 2019 /n software inc. - All rights reserved.
Cloud Storage Integrator 2016 Linux Edition - Version 16.0 [Build 7239]