IPWorks Cloud 2020 Python Edition

Questions / Feedback?

get_object Method

Downloads an object.

Syntax

def get_object(object_name: str) -> None: ...

Remarks

This methods downloads the object specified by ObjectName in the bucket currently selected by bucket. If the version_id property is non-empty, the specified version of the object is downloaded instead. The range property can be used to download a specific range of bytes from the object.

If local_file is set, the object data will be saved to the specified location; otherwise, the object data will be held by object_data.

To download and decrypt an encrypted object, set encryption_algorithm and encryption_password before calling this method.

Download Notes

In the simplest use-case, downloading an object looks like this:

s3.LocalFile = "../MyData.zip";
s3.GetObject(s3.Objects[0].Name);

Resuming Downloads

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

string downloadFile = "../MyData.zip";
s3.LocalFile = downloadFile;
s3.GetObject(s3.Objects[0].Name);

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

//Get the size of the partially downloaded file
s3.StartByte = new FileInfo(downloadFile).Length;
s3.GetObject(s3.Objects[0].Name);

Resuming Encrypted File Downloads

Resuming encrypted file downloads is only supported when local_file was set in the initial download attempt.

If local_file is set when beginning an encrypted download, the class creates a temporary file in TempPath to hold the encrypted data until the download is complete. If the download is interrupted, DownloadTempFile will be populated with the path of the temporary file that holds the partial data.

To resume, 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.

s3.LocalFile = "../MyData.zip";
s3.EncryptionPassword = "password";
s3.GetObject(s3.Objects[0].Name);

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

//Get the size of the partially downloaded temp file
s3.StartByte = new FileInfo(s3.Config("DownloadTempFile")).Length;
s3.GetObject(s3.Objects[0].Name);

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