Cloud Storage Integrator - Online Help
Cloud Storage Integrator
Questions / Feedback?

UploadFile Method

Uploads a new file.

Syntax

String __fastcall UploadFile(String fileTitle): String

Remarks

This method uploads a new 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 title specified by the FileTitle parameter should include a file extension.

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

This method returns the Id of the newly created file. 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 component 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 component 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 component. 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 component 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 component 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 and UseResumableUpload if True:

 
 
Copyright (c) 2017 /n software inc. - All rights reserved.
Build 1.0.6240.0