Minio --- 实战使用案例

minio.png
本章使用的minIO的前提是需要有一个完善的minIO服务器
  1. 最基本的python是有的 python版本在3.6以上..
  2. 使用pip 安装minIO pip install minio
初始化MinIO Client
参数 描述
endpoint 对象存储服务URL
access_key Access key是唯一标识你的账户的用户ID
secret_key Secret key是你账户的密码
secure true代表使用HTTPS
# 官方初始化实例:
from minio import Minio
from minio.error import ResponseError

minioClient = Minio('endpoint',
                  access_key='access_key',
                  secret_key='secret_key',
                  secure=True)
文件上传实例file-uploader.py
# 引入MinIO包。
from minio import Minio
from minio.error import (ResponseError, BucketAlreadyOwnedByYou,
                         BucketAlreadyExists)

# 使用endpoint、access key和secret key来初始化minioClient对象。
minioClient = Minio('play.min.io',
                    access_key='***********************',
                    secret_key='*********************',
                    secure=True)

# 调用make_bucket来创建一个存储桶。
try:
       minioClient.make_bucket("maylogs", location="us-east-1")
except BucketAlreadyOwnedByYou as err:
       pass
except BucketAlreadyExists as err:
       pass
except ResponseError as err:
       raise
else:
        try:
           minioClient.fput_object('maylogs', 'pumaserver_debug.log',                                           '/tmp/pumaserver_debug.log')
        except ResponseError as err:
               print(err)
操作API文档:
  1. 操作存储桶
    • make_bucket
    • list_buckets
    • bucket_exists
    • remove_bucket
    • list_objects
    • list_objects_v2
    • list_incomplate_uploads
  2. 存储桶策略
  3. 存储桶通知
  4. 操作文件对象
  5. 操作对象
  6. Presigned操作
    借鉴文档: https://docs.min.io/cn/python-client-quickstart-guide.html
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容