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

DownloadFile Method

Downloads a file.

Object Oriented Interface

public function doDownloadFile();

Procedural Interface

incloudstorage_box_do_downloadfile($res);

Remarks

DownloadFile downloads the file specified by ResourceId. Set ResourceId to the Id of the file to download before calling this method. If LocalFile is set the file will be saved to the specified location. If LocalFile is not set the file data will be held by ResourceData.

To decrypt an encrypted file set EncryptionAlgorithm and EncryptionPassword before calling this method.


box.ResourceId = "50619395801"
box.LocalFile = "../MyFile.zip";
box.DownloadFile();

Resuming Downloads

The class also supports resuming failed downloads by using the StartByte property. If the download was interrupted, set StartByte to the appropriate offset before calling this method to resume the download.


box.ResourceId = myId;
box.LocalFile = downloadFile;
box.DownloadFile();

//The transfer is interrupted and DownloadFile() above fails. Later, resume the download:

//Get the size of the partially download file
box.StartByte = new FileInfo(downloadFile).Length; 
box.ResourceId = myId;
box.LocalFile = downloadFile;
box.DownloadFile();

Resuming Encrypted File Downloads

Resuming encrypted file downloads is only supported when LocalFile was set in the initial download attempt. When beginning an encrypted download if LocalFile is set the class will create a temporary file in TempPath to hold the encrypted data until it is complete.

If the download is interrupted DownloadTempFile will be populated with the temporary file holding the partial data. When resuming, DownloadTempFile must be populated along with StartByte to allow the remainder of the encrypted data to be downloaded. Once the encrypted data is downloaded it will be decrypted and written to LocalFile.

box.ResourceId = myId;
box.LocalFile = downloadFile;
box.EncryptionPassword = "password";
box.DownloadFile();

//The transfer is interrupted and DownloadFile() above fails. Later, resume the download:

//Get the size of the partially download temp file
box.StartByte = new FileInfo(box.Config("DownloadTempFile")).Length; 
box.ResourceId = myId;
box.LocalFile = downloadFile;
box.EncryptionPassword = "password";
box.DownloadFile();

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