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

UploadFile Method

Uploads a file.

Syntax

public String uploadFile(String fileName);

Remarks

This method uploads a file. LocalFile specifies the file to upload. The data to upload may also be set in ResourceData or set by SetUploadStream.

The FileName parameter of UploadFile specifies the name of the file to be written.

A file can be uploaded to a specific folder by specifying the absolute path in the FileName parameter, or by setting ResourcePath to the folder. Absolute paths begin with a "/" character and must include the full path beginning at the root. For instance:

//Upload to the root folder
  dropbox.ResourcePath = ""; 
  string path = dropbox.UploadFile("test.txt");
  //path is "/test.txt"

//Upload to a folder (relative path)
  dropbox.CreateFolder("/uploadtest");
  path = dropbox.UploadFile("test.txt");
  //path is "/uploadtest/test.txt"

//Upload to a folder (absolute path)
  path = dropbox.UploadFile("/uploadtest/test.txt");
  //path is "/uploadtest/test.txt"

To encrypt a file before uploading set EncryptionAlgorithm and EncryptionPassword.

When the upload is complete the component will fire the UploadComplete event and UploadFile returns the absolute path to the uploaded file.

Upload Notes

Dropbox 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. Simple uploads are the only supported option when SetUploadStream is used.


dropbox.LocalFile = "../MyFile.zip";
dropbox.UploadFile("/folder/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 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. UploadSessionId is populated with the Id of 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 UploadSessionId 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.

The FragmentComplete event fires after each fragment is uploaded to indicate overall progress.


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

//The transfer is interrupted and UploadFile() above fails. Later, resume the download.
//Using the same instance StartByte and UploadSessionId are already populated 
//from the previous upload attempt
dropbox.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