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

UploadFile Method

Uploads, and optionally converts, a new file.

Syntax

 char* UploadFile(char* lpszfileName, char* lpszmimeType);

Remarks

This method uploads a new file and returns the Id of the newly-created file.

If LocalFile is set the file will be uploaded from the specified path. If LocalFile is not set the data in ResourceData will be used.

The name specified by the FileName parameter should include a file extension.

If MimeType is "", the file will be uploaded as-is and its MIME type will be automatically determined. The file can be converted to one of the Google formats by explicitly setting MimeType to one of the MIME types in the table below.

Before calling this method set ResourceIndex to -1 to clear the existing selection. The following properties may also optionally be set:

Note: ResourceName and ResourceMIMEType are overridden by the UploadFile parameters.

Original File Format Google FormatMIME Type
MS Word, OpenDocument Text, HTML, RTF, Plain Text Google Docs application/vnd.google-apps.document
MS Excel, OpenDocument Spreadsheet, CSV, TSV, Plain Text Google Sheets application/vnd.google-apps.spreadsheet
MS Powerpoint, OpenDocument Presentation Google Slides application/vnd.google-apps.presentation
PDF, JPEG, PNG, GIF, BMP (images are embedded in a Doc) Google Docs application/vnd.google-apps.document
Plain Text, JSON Google Apps Script application/vnd.google-apps.script

To encrypt a file before uploading set EncryptionAlgorithm and EncryptionPassword.

Upload Notes

Google Drive offers two ways to upload a file. For smaller files a simple upload option is provided to upload data in one request. This is the default option. For larger files uploads can be fragmented into multiple pieces, allowing resuming of uploads that may be interrupted.

Simple

By default the class uses the simple upload mechanism.


googledrive.LocalFile = "../MyFile.zip";
googledrive.UploadFile("MyFile.zip", "");

Resumable

To enable resumable uploads set UseResumableUpload to True. This is recommended for large files. The class will automatically fragment the specified file into smaller pieces and upload each individually. FragmentSize may be set to specify the size of the fragment if desired. The default fragment size is 10 MB.

When UseResumableUpload is set to True and UploadFile is called a resumable upload session is started by the class. ResumeURL is populated with the URL identifying the session. This value may be needed for additional operations if the upload does not complete normally. Additionally StartByte is updated as necessary by the class to indicate the current offset in the file.

If the upload is interrupted for any reason the upload may be resumed. To resume an upload verify that ResumeURL and StartByte are populated. If the same instance of the class is used these should already be populated and no special action is needed. Call UploadFile again to resume the upload at the specified StartByte offset.

If the upload is not resumed after some time the upload session will expire.

GetUploadStatus may be used to check the status of a resumable upload. The FragmentComplete event fires after each fragment is uploaded to indicate overall progress.


googledrive.LocalFile = "../MyFile.zip";
googledrive.UploadFile("MyFile.zip", "");

//The transfer is interrupted and UploadFile() above fails. Later, resume the download.
//Using the same instance StartByte and ResumeURL are already populated from the previous
//upload attempt.
googledrive.UploadFile("MyFile.zip", "");

The following additional properties are applicable when calling UploadFile when UseResumableUpload is True:

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