# Alibaba Cloud OSS SDK for Python v2
[](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-python-sdk-v2)
alibabacloud-oss-python-sdk-v2 is the v2 of the OSS SDK for the Python programming language
## [README in Chinese](README-CN.md)
## About
> - This Python SDK is based on the official APIs of [Alibaba Cloud OSS](http://www.aliyun.com/product/oss/).
> - Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring massive capacity, security, a low cost, and high reliability.
> - The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.
> - With this SDK, you can upload, download and manage data on any app anytime and anywhere conveniently.
## Running Environment
> - Python 3.8 or above.
## Installing
### Install the beta version through pip
```bash
$ pip install alibabacloud-oss-v2
```
### Install from the unzipped installer package directly
```bash
$ sudo python setup.py install
```
## Getting Started
#### List Bucket
```python
import alibabacloud_oss_v2 as oss
def main():
region = "cn-hangzhou"
# Loading credentials values from the environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Using the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = region
client = oss.Client(cfg)
# Create the Paginator for the ListBuckets operation
paginator = client.list_buckets_paginator()
# Iterate through the bucket pages
for page in paginator.iter_page(oss.ListBucketsRequest(
)
):
for o in page.buckets:
print(f'Bucket: {o.name}, {o.location}, {o.creation_date} {o.resource_group_id}')
if __name__ == "__main__":
main()
```
#### List Objects
```python
import alibabacloud_oss_v2 as oss
def main():
region = "cn-hangzhou"
bucket_name = "your bucket name"
# Loading credentials values from the environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Using the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = region
client = oss.Client(cfg)
# Create the Paginator for the ListObjectsV2 operation
paginator = client.list_objects_v2_paginator()
# Iterate through the object pages
for page in paginator.iter_page(oss.ListObjectsV2Request(
bucket=bucket_name
)
):
for o in page.contents:
print(f'Object: {o.key}, {o.size}, {o.last_modified}')
if __name__ == "__main__":
main()
```
#### Put Object
```python
import alibabacloud_oss_v2 as oss
def main():
region = "cn-hangzhou"
bucket_name = "your bucket name"
object_name = "your object name"
local_file = "your local file path"
# Loading credentials values from the environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Using the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = region
client = oss.Client(cfg)
with open(local_file, 'rb') as f:
result = client.put_object(oss.PutObjectRequest(
bucket=bucket_name,
key=object_name,
body=f,
))
print(f'put object successfully, ETag {result.etag}')
if __name__ == "__main__":
main()
```
## Complete Example
More example projects can be found in the `sample` folder
### Running Example
> - Go to the sample code folder `sample`。
> - Configure credentials values from the environment variables, like `export OSS_ACCESS_KEY_ID="your access key id"`, `export OSS_ACCESS_KEY_SECRET="your access key secrect"`
> - Take list_buckets.python as an example,run `python list_buckets.python --region cn-hangzhou` command。
## Resources
[Developer Guide](DEVGUIDE-CN.md) - Use this document to learn how to get started and use this sdk.
## License
> - Apache-2.0, see [license file](LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/aliyun/alibabacloud-oss-python-sdk-v2",
"name": "alibabacloud-oss-v2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "alibabacloud, oss",
"author": "Alibaba Cloud OSS SDK",
"author_email": "sdk-team@alibabacloud.com",
"download_url": "https://files.pythonhosted.org/packages/22/ea/ac696d45efd807d3c2eab96b35369d285adc8fee27ff5c1f14cbe3146d51/alibabacloud-oss-v2-1.1.3.tar.gz",
"platform": "any",
"description": "# Alibaba Cloud OSS SDK for Python v2\n\n[](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-python-sdk-v2)\n\nalibabacloud-oss-python-sdk-v2 is the v2 of the OSS SDK for the Python programming language\n\n## [README in Chinese](README-CN.md)\n\n## About\n> - This Python SDK is based on the official APIs of [Alibaba Cloud OSS](http://www.aliyun.com/product/oss/).\n> - Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring massive capacity, security, a low cost, and high reliability. \n> - The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.\n> - With this SDK, you can upload, download and manage data on any app anytime and anywhere conveniently. \n\n## Running Environment\n> - Python 3.8 or above. \n\n## Installing\n### Install the beta version through pip\n```bash\n$ pip install alibabacloud-oss-v2\n```\n\n### Install from the unzipped installer package directly\n```bash\n$ sudo python setup.py install\n```\n\n## Getting Started\n#### List Bucket\n```python\nimport alibabacloud_oss_v2 as oss\n\ndef main():\n\n region = \"cn-hangzhou\"\n\n # Loading credentials values from the environment variables\n credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()\n\n # Using the SDK's default configuration\n cfg = oss.config.load_default()\n cfg.credentials_provider = credentials_provider\n cfg.region = region\n\n client = oss.Client(cfg)\n\n # Create the Paginator for the ListBuckets operation\n paginator = client.list_buckets_paginator()\n\n # Iterate through the bucket pages\n for page in paginator.iter_page(oss.ListBucketsRequest(\n )\n ):\n for o in page.buckets:\n print(f'Bucket: {o.name}, {o.location}, {o.creation_date} {o.resource_group_id}')\n\nif __name__ == \"__main__\":\n main()\n\n```\n\n#### List Objects\n```python\nimport alibabacloud_oss_v2 as oss\n\ndef main():\n\n region = \"cn-hangzhou\"\n bucket_name = \"your bucket name\"\n \n # Loading credentials values from the environment variables\n credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()\n\n # Using the SDK's default configuration\n cfg = oss.config.load_default()\n cfg.credentials_provider = credentials_provider\n cfg.region = region\n\n client = oss.Client(cfg)\n\n # Create the Paginator for the ListObjectsV2 operation\n paginator = client.list_objects_v2_paginator()\n\n # Iterate through the object pages\n for page in paginator.iter_page(oss.ListObjectsV2Request(\n bucket=bucket_name\n )\n ):\n for o in page.contents:\n print(f'Object: {o.key}, {o.size}, {o.last_modified}')\n\nif __name__ == \"__main__\":\n main()\n\n```\n\n#### Put Object\n```python\nimport alibabacloud_oss_v2 as oss\n\ndef main():\n\n region = \"cn-hangzhou\"\n bucket_name = \"your bucket name\"\n object_name = \"your object name\"\n local_file = \"your local file path\"\n\n # Loading credentials values from the environment variables\n credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()\n\n # Using the SDK's default configuration\n cfg = oss.config.load_default()\n cfg.credentials_provider = credentials_provider\n cfg.region = region\n\n\n client = oss.Client(cfg)\n\n with open(local_file, 'rb') as f:\n result = client.put_object(oss.PutObjectRequest(\n bucket=bucket_name,\n key=object_name,\n body=f,\n ))\n\n print(f'put object successfully, ETag {result.etag}')\n\n\nif __name__ == \"__main__\":\n main()\n\n```\n\n## Complete Example\nMore example projects can be found in the `sample` folder \n\n### Running Example\n> - Go to the sample code folder `sample`\u3002\n> - Configure credentials values from the environment variables, like `export OSS_ACCESS_KEY_ID=\"your access key id\"`, `export OSS_ACCESS_KEY_SECRET=\"your access key secrect\"`\n> - Take list_buckets.python as an example\uff0crun `python list_buckets.python --region cn-hangzhou` command\u3002\n\n## Resources\n[Developer Guide](DEVGUIDE-CN.md) - Use this document to learn how to get started and use this sdk.\n\n## License\n> - Apache-2.0, see [license file](LICENSE)\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Alibaba Cloud OSS (Object Storage Service) SDK V2 for Python",
"version": "1.1.3",
"project_urls": {
"Homepage": "https://github.com/aliyun/alibabacloud-oss-python-sdk-v2"
},
"split_keywords": [
"alibabacloud",
" oss"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3ac7e751e235cf34a90b6459da648282710971d6ca7a7c668c3fbb1106a19d97",
"md5": "d71852a5ae8bd70785a18e246be0ed76",
"sha256": "b83631a4c9340f1036c25339d1c8d5f72d1168cb6f0491052d49fec3c8b86d32"
},
"downloads": -1,
"filename": "alibabacloud_oss_v2-1.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d71852a5ae8bd70785a18e246be0ed76",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 205863,
"upload_time": "2025-07-30T08:19:58",
"upload_time_iso_8601": "2025-07-30T08:19:58.773424Z",
"url": "https://files.pythonhosted.org/packages/3a/c7/e751e235cf34a90b6459da648282710971d6ca7a7c668c3fbb1106a19d97/alibabacloud_oss_v2-1.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "22eaac696d45efd807d3c2eab96b35369d285adc8fee27ff5c1f14cbe3146d51",
"md5": "b9c275a5cf31ac22377a2594a7923333",
"sha256": "e3f024b3cc227e97976bd240a16c0a876e83b4f738eb1d06c66a0e523d0467c2"
},
"downloads": -1,
"filename": "alibabacloud-oss-v2-1.1.3.tar.gz",
"has_sig": false,
"md5_digest": "b9c275a5cf31ac22377a2594a7923333",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 154964,
"upload_time": "2025-07-30T08:19:59",
"upload_time_iso_8601": "2025-07-30T08:19:59.985398Z",
"url": "https://files.pythonhosted.org/packages/22/ea/ac696d45efd807d3c2eab96b35369d285adc8fee27ff5c1f14cbe3146d51/alibabacloud-oss-v2-1.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-30 08:19:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aliyun",
"github_project": "alibabacloud-oss-python-sdk-v2",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "alibabacloud-oss-v2"
}