# Alibaba Cloud OSS SDK for Python v2
[![GitHub version](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-python-sdk-v2.svg)](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-python-sdk-v2)
alibabacloud-oss-python-sdk-v2 is the Developer Preview for 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 pre release version through pip
```bash
$ pip install --pre 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 sucessfully, 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.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/65/d1/2ae24f085850be2c18377aa69fe623528fde3af48b1474b3838cc6153d1c/alibabacloud-oss-v2-1.0.1.dev0.tar.gz",
"platform": "any",
"description": "# Alibaba Cloud OSS SDK for Python v2\n\n[![GitHub version](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-python-sdk-v2.svg)](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-python-sdk-v2)\n\nalibabacloud-oss-python-sdk-v2 is the Developer Preview for 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 pre release version through pip\n```bash\n$ pip install --pre 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 sucessfully, 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.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.0.1.dev0",
"project_urls": {
"Homepage": "https://github.com/aliyun/alibabacloud-oss-python-sdk-v2"
},
"split_keywords": [
"alibabacloud",
" oss"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "65d12ae24f085850be2c18377aa69fe623528fde3af48b1474b3838cc6153d1c",
"md5": "4acd194de35b3c4f8e0dec8520b3df4a",
"sha256": "02154e1b2b28825ddfb131b82fb02fc9a30723f04a6813c58bf86a07c8ad8446"
},
"downloads": -1,
"filename": "alibabacloud-oss-v2-1.0.1.dev0.tar.gz",
"has_sig": false,
"md5_digest": "4acd194de35b3c4f8e0dec8520b3df4a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 126970,
"upload_time": "2024-12-03T07:54:12",
"upload_time_iso_8601": "2024-12-03T07:54:12.512537Z",
"url": "https://files.pythonhosted.org/packages/65/d1/2ae24f085850be2c18377aa69fe623528fde3af48b1474b3838cc6153d1c/alibabacloud-oss-v2-1.0.1.dev0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-03 07:54:12",
"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"
}