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

UploadFile Method

Uploads a file.

Syntax

 char* UploadFile(char* lpszFileTitle);

Remarks

This method uploads a file to the current drive. LocalFile specifies the file to upload. The data to upload may also be set in ResourceData .

The FileTitle parameter of UploadFile specifies the name of the file to be written in the drive.

To upload a file in a specific folder set ResourceParentId or ResourceParentPath to indicate the parent folder. If both are specified ResourceParentId takes precedence. If both are unspecified the drive root is assumed.

To encrypt a file before uploading set EncryptionAlgorithm and EncryptionPassword.

The UploadFile method returns the Id of the resource which was uploaded.

Upload Notes

Microsoft OneDrive 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. There is a limit to how large files can be if you wish to upload them using the default simple upload; 100 MB if using the legacy API, and 4 MB if using the Graph API.


onedrive.LocalFile = "../MyFile.zip";
onedrive.UploadFile("MyFile.zip");

The following properties are applicable when calling UploadFile and UseResumableUpload if False (default - simple upload):

Resumable

To enable resumable uploads set UseResumableUpload to True. This is recommended for files larger than 10 MB. 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 a resumable upload is interrupted for any reason, AbortUpload may be called to cancel the upload. If the upload is not resumed after some time the upload session will expire. UploadExpDate may be checked to determine when the upload session expires.

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.


onedrive.LocalFile = "../MyFile.zip";
onedrive.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.
onedrive.UploadFile("MyFile.zip");

The following 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]