flask API与Minio object storag连接时出现问题

2024-05-29 05:09:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我已附上下面的代码。它直接从min.io的文档中复制。我正在尝试连接flaskapi与minio对象存储,但我得到的问题。我已经更改了config.json文件中的访问密钥和密钥,但仍然无法从浏览器访问minio

# Import MinIO library.
from minio import Minio
from minio.error import (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")
except BucketAlreadyOwnedByYou as err:
       pass
except BucketAlreadyExists as err:
       pass
except ResponseError as err:
       raise

# Put an object 'pumaserver_debug.log' with contents from 'pumaserver_debug.log'.
try:
       minioClient.fput_object('maylogs', 'pumaserver_debug.log', '/tmp/pumaserver_debug.log')
except ResponseError as err:
       print(err)

Tags: fromiodebuglogbucketaswith密钥

热门问题