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

UploadFile Method

Uploads a file.

Syntax

public String uploadFile(String fileTitle);

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 or set by SetUploadStream.

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 component uses the simple upload mechanism. Only files up to 100 MB can be uploaded using the default simple upload. Additionally, simple uploads are the only supported option when SetUploadStream is used.


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 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 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 and UseResumableUpload if True:

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