minio python library for amazon s3兼容的python云存储

minio的Python项目详细描述


minio python library for amazon s3兼容云存储Slack

minio python客户端sdk提供了简单的api来访问任何与amazon s3兼容的对象存储服务器。

本快速入门指南将向您展示如何安装客户端sdk并执行示例python程序。有关api和示例的完整列表,请查看Python Client API Reference文档。

本文档假设您有一个工作的Python设置。

最低要求

  • python 2.7或更高版本

从PIP下载

pip install minio

从PIP3下载

pip3 install minio

从源下载

git clone https://github.com/minio/minio-py
cd minio-py
python setup.py install

初始化minio客户端

您需要四项才能连接到minio对象存储服务器。

ParamsDescription
endpointURL to object storage service.
access_keyAccess key is like user ID that uniquely identifies your account.
secret_keySecret key is the password to your account.
secureSet this value to 'True' to enable secure (HTTPS) access.
fromminioimportMiniofromminio.errorimportResponseErrorminioClient=Minio('play.min.io',access_key='Q3AM3UQ867SPQQA43P2F',secret_key='zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',secure=True)

快速入门示例-文件上载程序

这个示例程序连接到一个minio对象存储服务器,在服务器上创建一个bucket,然后将一个文件上传到bucket。

在本例中,我们将使用运行在https://play.min.io的minio服务器。请随意使用此服务进行测试和开发。此示例中显示的访问凭据对公众开放。

文件上载程序.py
# Import MinIO library.fromminioimportMiniofromminio.errorimport(ResponseError,BucketAlreadyOwnedByYou,BucketAlreadyExists)# Initialize minioClient with an endpoint and access/secret keys.minioClient=Minio('play.min.io',access_key='Q3AM3UQ867SPQQA43P2F',secret_key='zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',secure=True)# Make a bucket with the make_bucket API call.try:minioClient.make_bucket("maylogs",location="us-east-1")exceptBucketAlreadyOwnedByYouaserr:passexceptBucketAlreadyExistsaserr:passexceptResponseErroraserr:raiseelse:# Put an object 'pumaserver_debug.log' with contents from 'pumaserver_debug.log'.try:minioClient.fput_object('maylogs','pumaserver_debug.log','/tmp/pumaserver_debug.log')exceptResponseErroraserr:print(err)

运行文件上载程序
python file_uploader.py

mc ls play/maylogs/
[2016-05-27 16:41:37 PDT]  12MiB pumaserver_debug.log

API参考

这里有完整的api引用。

API参考:bucket操作

api参考:bucket策略操作

api参考:bucket通知操作

api引用:文件对象操作

api引用:对象操作

API参考:预先指定的操作

完整示例

完整示例:bucket操作

完整示例:bucket策略操作

完整示例:bucket通知操作

完整示例:文件对象操作

完整示例:对象操作

完整示例:预先指定的操作

进一步了解

贡献

Contributors Guide

PYPIBuild StatusBuild status

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何为我的jsp/java web项目实现使用twitter登录   java KeyListener是否停止使用动作或鼠标Listener?   java Android:RecyclerView表现为GridLayout   java Appassembler在生成的脚本中构建错误的类路径   Java 11 JLink获取错误:自动模块不能与JLink:com一起使用。微软sqlserver。来自文件的jdbc   java如何检查Android tabview中打开的选项卡   java非固定大小Fenwick树实现   java如何使用java8的completableFuture实现forEach列表循环   java如何在Eclipse中指定测试类路径   java我们可以中断一个已经获得锁的线程吗?   java使用JSONPATH规范化嵌套json   在java中创建异常列表