All Products
Search
Document Center

Object Storage Service:Objects/files (Python SDK V1)

Last Updated:Aug 08, 2025

The Alibaba Cloud OSS SDK for Python provides a wide range of API operations for managing objects and files in OSS. This document describes how to use these operations to upload, download, and manage files, along with manage directories and data indexes. The SDK provides solutions for processing large amounts of data in batches and implementing efficient file access control.

Upload files

You can use the Alibaba Cloud Python SDK to upload local files to an OSS bucket. The SDK supports multiple upload methods to suit different scenarios, such as simple upload, append upload, resumable upload, and multipart upload. For example, when you transfer large files or experience unstable network connectivity, resumable upload and multipart upload ensure data integrity and reliability. The SDK also provides a progress bar chart feature to help you monitor the upload process.

Download files

You can use the Python SDK to download objects from OSS to a local disk or read them directly into memory. The SDK supports range download and resumable download. This lets you efficiently retrieve the required data segments, even in low-bandwidth environments. This feature is especially useful when you process large datasets because you can download only the necessary parts, which saves time and resources.

Manage files

In addition to basic upload and download operations, the Python SDK supports advanced file management tasks. These tasks include changing the storage class, setting metadata, renaming, and deleting files. You can also add descriptive tags to files for easier categorization and searching, or configure lifecycle rules to automatically delete expired content. These features give developers flexible control over all files in their buckets.

Manage directories

In addition to operations on individual files, the Python SDK also supports directory management. You can create, list, and delete directories, and traverse all objects within a specific directory. This is useful for applications that need to maintain complex file structures. For example, you can use this feature to build an online education platform that stores learning materials categorized by course.

Data indexing

For large-scale datasets, the Python SDK includes a powerful data indexing feature that lets you efficiently retrieve information stored in OSS. By creating an effective indexing policy, you can quickly locate required records, even within petabytes of data. This feature greatly improves system response speed and service quality.

Notes

  • Before using the Alibaba Cloud Python SDK, ensure that the development environment is correctly installed and configured.

  • When uploading or downloading files with the Python SDK, ensure you have stable network connectivity. For important data operations, such as deletion, back up your data beforehand.

References