IPWorks Cloud 2020 Python Edition

Questions / Feedback?

upload_file Method

Uploads a new file resource.

Syntax

def upload_file(new_file_path: str) -> str: ...

Remarks

This method uploads a new file resource at the specified NewFilePath in the share currently selected by share. The path of the newly-created file is returned.

Any parent folders included in NewFilePath must already exist.

If the SendMetadata configuration setting is enabled when this method is called, all items in the Metadata* properties will be sent along with the creation request.

If local_file is set the file will be uploaded from the specified path. If local_file is not set the data in resource_data will be used.

To encrypt the file before uploading it, set encryption_algorithm and encryption_password.

Upload Notes

The upload_file method is a convenience method that performs a resumable file upload. When called, the class first uses create_file to initialize a new file entry on the server; and then it fragments the file data into smaller pieces and calls put_range multiple times in succession to upload those fragments. The fragment size is fixed at 4MB (this is a server limitation that cannot be changed).

During the upload, the on_fragment_complete event fires after each fragment is uploaded to indicate overall progress. The class also updates start_byte as necessary to indicate the current offset in the file.

If the upload is interrupted for any reason, resuming it is easy. First, verify that start_byte is populated (if the same instance of the class is used, they should already be populated, and no special action should be needed). Then call upload_file again to resume the upload at the specified start_byte offset.

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

//The transfer is interrupted and UploadFile() above fails. Later, resume the download.
//Using the same instance StartByte is already populated from the previous upload attempt.
azurefile.UploadFile("MyFile.zip");

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