alibabacloud-oss-v2


Namealibabacloud-oss-v2 JSON
Version 1.0.0.dev0 PyPI version JSON
download
home_pagehttps://github.com/aliyun/alibabacloud-oss-python-sdk-v2
SummaryAlibaba Cloud OSS (Object Storage Service) SDK V2 for Python
upload_time2024-09-26 12:49:49
maintainerNone
docs_urlNone
authorAlibaba Cloud OSS SDK
requires_python>=3.8
licenseApache License 2.0
keywords alibabacloud oss
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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 official release 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 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。

## 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/7f/32/da50642d2dd6ff8fbe77421868878f00f3b6f6fa958df9f2fff2e0af37f0/alibabacloud-oss-v2-1.0.0.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 official release 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 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## 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.0.dev0",
    "project_urls": {
        "Homepage": "https://github.com/aliyun/alibabacloud-oss-python-sdk-v2"
    },
    "split_keywords": [
        "alibabacloud",
        " oss"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7f32da50642d2dd6ff8fbe77421868878f00f3b6f6fa958df9f2fff2e0af37f0",
                "md5": "086e4ac3d5a3b70301b9a357fc83f13b",
                "sha256": "31612af0f25b025573830b4456b9ef045dca76424fe6a045cfe03c4d17d3bf30"
            },
            "downloads": -1,
            "filename": "alibabacloud-oss-v2-1.0.0.dev0.tar.gz",
            "has_sig": false,
            "md5_digest": "086e4ac3d5a3b70301b9a357fc83f13b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 96172,
            "upload_time": "2024-09-26T12:49:49",
            "upload_time_iso_8601": "2024-09-26T12:49:49.921331Z",
            "url": "https://files.pythonhosted.org/packages/7f/32/da50642d2dd6ff8fbe77421868878f00f3b6f6fa958df9f2fff2e0af37f0/alibabacloud-oss-v2-1.0.0.dev0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-26 12:49:49",
    "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"
}
        
Elapsed time: 4.77268s