最近在使用minio做图片、文件存储,在使用过程中遇到一些问题,总结记录下来。这里不对minio做过多介绍,具体资料自行查找。
1、官网地址 https://min.io/
2、github地址 https://github.com/minio/minio
3、windows 服务端下载地址
https://dl.minio.io/server/minio/release/windows-amd64/minio.exe
4、安装启动
启动一个cmd窗口,进入minio.exe所在文件夹,输入如下命令
.\minio.exe server D:\html\minio
cmd窗口内容如下:
Microsoft Windows [版本 10.0.18363.1198]
(c) 2019 Microsoft Corporation。保留所有权利。
C:\Users\Awen>d:
D:\>cd D:\Software\minio
D:\Software\minio>.\minio.exe server D:\Software\minio
+----------------------------------------------------------------+
| You are running an older version of MinIO released 5 hours ago |
| Update: Run `mc admin update` |
+----------------------------------------------------------------+
Endpoint: http://169.254.67.253:9000 http://169.254.197.248:9000 http://192.168.31.217:9000 http://169.254.180.173:9000 http://169.254.114.36:9000 http://169.254.178.35:9000 http://192.168.137.1:9000 http://192.168.191.1:9000 http://192.168.197.1:9000 http://192.168.245.1:9000 http://127.0.0.1:9000
AccessKey: minioadmin
SecretKey: minioadmin
Browser Access:
http://169.254.67.253:9000 http://169.254.197.248:9000 http://192.168.31.217:9000 http://169.254.180.173:9000 http://169.254.114.36:9000 http://169.254.178.35:9000 http://192.168.137.1:9000 http://192.168.191.1:9000 http://192.168.197.1:9000 http://192.168.245.1:9000 http://127.0.0.1:9000
Command-line Access: https://docs.min.io/docs/minio-client-quickstart-guide
$ mc.exe alias set myminio http://169.254.67.253:9000 minioadmin minioadmin
Object API (Amazon S3 compatible):
Go: https://docs.min.io/docs/golang-client-quickstart-guide
Java: https://docs.min.io/docs/java-client-quickstart-guide
Python: https://docs.min.io/docs/python-client-quickstart-guide
JavaScript: https://docs.min.io/docs/javascript-client-quickstart-guide
.NET: https://docs.min.io/docs/dotnet-client-quickstart-guide
Detected default credentials 'minioadmin:minioadmin', please change the credentials immediately using 'MINIO_ACCESS_KEY' and 'MINIO_SECRET_KEY'
输入:
AccessKey: minioadmin
SecretKey: minioadmin
即可登录minio的管理界面。
5、创建桶和上传图片(注:需要先创建桶,再上传图片):
点击creare bucket创建桶, 并命名(这里的桶可以看作为文件夹),这里我创建了一个picture文件夹。
点击upload file上传文件(可手动选中多个上传):
也可手动批量删除和下载。
6、Python连接Minio服务器并上传文件:
如果没有安装minio,则 pip install minio
from minio import Minio
from minio.error import (ResponseError, BucketAlreadyOwnedByYou,
BucketAlreadyExists)
# 使用endpoint、access key和secret key来初始化minioClient对象。
minioClient = Minio('192.168.31.217:9000',
access_key='minioadmin',
secret_key='minioadmin',
secure=False)
try:
minioClient.fput_object('pictures', '4.jpg', "D:/Pycharmproject2020/Django_project/django_learn/chapter06/uploadfile_demo/4.jpg")
print('成功')
except ResponseError as err:
print(err)
图片4.jpg上传成功:
7、修改密码:
打开D:\Software\minio\.minio.sys\config
打开 config.json 文件,直接搜索 access_key 和 secret_key 修改后面value中的值就可以了
下一篇:Python利用Minio API实现文件上传下载、删除等操作
参考:minio白皮书:http://www.voidcn.com/article/p-pazuhqzs-byz.html
Minio Cookbook 中文版链接:https://www.bookstack.cn/read/miniocookbookzh/24.md
Windows下的Minio服务修改密码,自定义密码:https://blog.csdn.net/weixin_44981485/article/details/106809902