IPWorks Cloud 2020 Python Edition

Questions / Feedback?

download Method

Download the specified file.

Syntax

def download() -> None: ...

Remarks

This method downloads the specified file. Set remote_file to the name the file to download before calling this method. If remote_file only specifies a filename it will be downloaded from the path specified by remote_path. remote_file may also be set to an absolute path.

If local_file is set the file will be saved to the specified location. If local_file is not set the file data will be held by resource_data.

To decrypt an encrypted file set encryption_algorithm and encryption_password before calling this method.

cloudstorage.RemotePath = "My Folder";
cloudstorage.RemoteFile = "MyFile.zip";
cloudstorage.LocalFile = "../MyFile.zip";
cloudstorage.Download();

Resuming Downloads

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

cloudstorage.RemotePath = myRemoteFolder;
cloudstorage.RemoteFile = myRemoteFile;
cloudstorage.LocalFile = downloadFile;
cloudstorage.Download();

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

//Get the size of the partially downloaded file
cloudstorage.StartByte = new FileInfo(downloadFile).Length; 
cloudstorage.RemotePath = myRemoteFolder;
cloudstorage.RemoteFile = myRemoteFile;
cloudstorage.LocalFile = downloadFile;
cloudstorage.Download();

Resuming Encrypted File Downloads

Resuming encrypted file downloads is only supported when local_file was set in the initial download attempt. When beginning an encrypted download if local_file 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 start_byte to allow the remainder of the encrypted data to be downloaded. Once the encrypted data is downloaded it will be decrypted and written to local_file.

cloudstorage.RemotePath = myRemoteFolder;
cloudstorage.RemoteFile = myRemoteFile;
cloudstorage.LocalFile = downloadFile;
cloudstorage.EncryptionPassword = "password";
cloudstorage.Download();

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

//Get the size of the partially download temp file
cloudstorage.StartByte = new FileInfo(cloudstorage.Config("DownloadTempFile")).Length; 
cloudstorage.RemotePath = myRemoteFolder;
cloudstorage.RemoteFile = myRemoteFile;
cloudstorage.LocalFile = downloadFile;
cloudstorage.EncryptionPassword = "password";
cloudstorage.Download();

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 Python Edition - Version 20.0 [Build 8265]