我试图将文件保存到存储桶:
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
try:
minioClient.make_bucket("testbuck", location = "us-east-1")
except BucketAlreadyOwnedByYou as err:
pass
except BucketAlreadyExists as err:
pass
except ResponseError as err:
raise
else:
try:
print(filename)
minioClient.fput_object('testbuck', filename, image)
except ResponseError as err:
print(err)
但是得到错误:Message: {0}'.format(error.message))
InvalidXMLError: InvalidXMLError: message: "Error" XML is not parsable. Message: syntax error: line 1, column 0
我在后端和烧瓶中新手,无法弄清楚我做错了什么!谢谢你的耐心
答案 0 :(得分:0)
pymino的 minioClient.fput_object()方法期望现有存储段名称,对象名称得以保留以及文件的文件路径被上传。
用法:
minioClient.fput_object(存储桶名称,对象名称,文件路径)
在开头添加以下内容,将image
替换为文件路径。
UPLOAD_FOLDER = '/path/to/the/uploads'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER`
在启用 fput_object 函数之前添加以下内容:
filename = secure_filename(file.filename)
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
示例:
minioClient.fput_object(“ testbuck”,文件名,文件路径)