输入关键字搜索文档

SDK-Python

概述

若您需要使用 Python 来访问土星云的对象存储服务,我们可以使用第三方的 boto3 接口。它可以看作是符合 AWS S3 API 标准的 Python SDK。关于如何使用 boto3,请参考https://boto3.readthedocs.io/en/latest/

安装 pip 和 boto3

pip 的安装:https://pip.pypa.io/en/stable/installing/ 使用 aws sdk-python 前,您需要先安装 boto3 包,命令如下(请确定 pip 已经安装):

pip install boto3

创建 client

下面我们给出了一个创建 client 的例子,更多信息请参考:http://boto3.readthedocs.io/en/latest/reference/services/s3.html

3

API 功能 API 名称 SDK 接口
列举存储桶 Get Service boto3.client.list_buckets()
列举文件对象 Get Bucket boto3.client.list_objects()
创建存储桶 Put Bucket boto3.client.create_bucket()
确认存储桶 Head Bucket boto3.client.head_bucket()
删除存储桶 Delete Bucket boto3.client.delete_bucket()
获取存储 ACL Get Bucket ACL boto3.client.get_bucket_acl()
设置存储 ACL Set Bucket ACL boto3.client.put_bucket_acl()
获取存储位置 Get Bucket Location boto3.client.get_bucket_location()
上传文件对象 Put Object boto3.client.put_object()
下载文件对象 Get Object boto3.client.get_object()
删除文件对象 Delete Object boto3.client.delete_object()
批量删除文件对象 Delete Multiple Objects boto3.client.delete_objects()
获取文件元信息 Head Object boto3.client.head_object()