python中使用minio对象存储

# minio_client.py

from minio import Minio
from minio.error import InvalidResponseError
import os


# 定义一个类,用于minio的操作
class MinioClient(object):
    def __init__(self, endpoint='0.0.0.0:9000', access_key='UGkZSACKXxMbtaurC',
                 secret_key='wb59XZR95yMla0Z3QasdsaddzSVAN3f6zEsxs', secure=False):
        self.minioClient = Minio(endpoint,
                                 access_key=access_key,
                                 secret_key=secret_key,
                                 secure=secure)

    #     上传文件,并返回文件的url
    def upload_file(self, bucket_name, file_name, file_path):
        try:
            self.minioClient.fput_object(bucket_name, file_name, file_path)
            url = self.minioClient.presigned_get_object(bucket_name, file_name)
            return url
        except InvalidResponseError as err:
  

你可能感兴趣的:(笔记,python)