MinIO初体验
AI-摘要
JinzAI GPT
AI初始化中...
介绍自己
生成本文简介
推荐相关文章
前往主页
前往tianli博客
1.使用docker部署MinIO
mkdir -p ~/minio/data
docker run \
-p 9000:9000 \
-p 9001:9001 \
--name minio \
-v ~/minio/data:/data \
-e "MINIO_ROOT_USER=ROOTNAME" \
-e "MINIO_ROOT_PASSWORD=CHANGEME123" \
quay.io/minio/minio server /data --console-address ":9001"
2.http://ip:9000 登陆MinIO
3.新增AccessKey
4.使用python代码创建bucket,并上传文件
# file_uploader.py MinIO Python SDK example
from minio import Minio
from minio.error import S3Error
END_POINT = '110.18.*.*:9000'
ACCESS_KEY = '****'
SECRET_KEY = '****'
IS_HTTPS = False
def main():
# Create a client with the MinIO server playground, its access key
# and secret key.
client = Minio(END_POINT,
access_key=ACCESS_KEY,
secret_key=SECRET_KEY,
secure=IS_HTTPS
)
# The file to upload, change this path if needed
source_file = "C:/ip.txt"
# The destination bucket and filename on the MinIO server
bucket_name = "python-test-bucket"
destination_file = "my-test-file.txt"
# Make the bucket if it doesn't exist.
found = client.bucket_exists(bucket_name)
if not found:
client.make_bucket(bucket_name)
print("Created bucket", bucket_name)
else:
print("Bucket", bucket_name, "already exists")
# Upload the file, renaming it in the process
client.fput_object(
bucket_name, destination_file, source_file,
)
print(
source_file, "successfully uploaded as object",
destination_file, "to bucket", bucket_name,
)
if __name__ == "__main__":
try:
main()
except S3Error as exc:
print("error occurred.", exc)
5.设置bucket policy
6.使用分享的链接查看图片
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 Jinz
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果