All Products
Search
Document Center

Object Storage Service:Upload files (Python SDK V2)

Last Updated:Jul 31, 2025

The OSS SDK for Python V2 provides various operations for uploading files. You can select the operation that best fits your scenario.

Type

Operation name

Description

Simple upload (Python SDK V2)

client.put_object

  • Performs a simple upload. The maximum size of an object that can be uploaded is 5 GiB.

  • Supports 64-bit cyclic redundancy check (CRC-64) data validation. This feature is enabled by default.

  • Supports progress bar charts.

  • The request body is of the io.Reader type. If the io.Seeker type is supported, retransmission is performed if the upload fails.

client.put_object_from_file

  • Provides the same features as the client.put_object operation.

  • The request body data is obtained from a file path.

Append upload (Python SDK V2)

client.append_object

  • Performs an append upload. The maximum size of the final object is 5 GiB.

  • Supports CRC-64 data validation. This feature is enabled by default.

  • Supports progress bar charts.

  • The request body is of the BodyType type. Retransmission is performed if the upload fails. This operation is not idempotent. Retransmission may fail.

AppendOnlyFile operation

AppendOnlyFile.write

AppendOnlyFile.write_from

  • Provides the same features as the client.append_object operation.

  • Optimizes fault tolerance for retransmission failures.

Multipart upload (Python SDK V2)

Multipart upload operations

client.initiate_multipart_upload

client.upload_part

client.complete_multipart_upload

  • Performs a multipart upload. The maximum size of a part is 5 GiB. The maximum size of an object is 48.8 TiB.

  • The upload_part operation supports CRC-64 validation. This feature is enabled by default.

  • The upload_part operation supports progress bar charts.

  • The request body for the upload_part operation is of the BodyType type. The str, bytes, Iterable[bytes], IO[str], and IO[bytes] types are also supported.

Form upload (Python SDK V2)

/

  • Generates information such as a Post signature and a Post policy, and calls the HTTP POST method to upload a file to OSS.

Upload using a signed URL (Python SDK V2)

client.presign

  • Generates a signed URL for the PUT method that has an expiration time. This allows other users to temporarily upload files.

File upload manager (Python SDK V2)

Uploader.upload_from

  • Encapsulates simple upload and multipart upload operations. The maximum size of an object that can be uploaded is 48.8 TiB.

  • Supports CRC-64 data validation. This feature is enabled by default.

  • Supports progress bar charts.

  • The request body parameter is of the IO[bytes] type.

Uploader.upload_file

  • Provides the same features as the Uploader.upload_from operation.

  • The request body data is obtained from a file path.

  • Supports resumable upload.