minio测试.py 942 B

123456789101112131415161718192021222324252627282930313233343536
  1. from minio import Minio
  2. import os
  3. client = Minio(
  4. "192.168.77.249:9000",
  5. access_key="pZEwCGnpNN05KPnmC2Yh",
  6. secret_key="KfJRuWiv9pVxhIMcFqbkv8hZT9SnNTZ6LPx592D4",
  7. secure=False
  8. )
  9. MINIO_ENDPOINT = "192.168.77.249:9000"
  10. MINIO_BUCKET = "grading"
  11. MINIO_BASE_PREFIX = "raspi_img_data"
  12. DATA_HOST_URL = f"http://{MINIO_ENDPOINT}/{MINIO_BUCKET}/{MINIO_BASE_PREFIX}"
  13. # try:
  14. # # 2. 检查存储桶是否存在
  15. # found = client.bucket_exists(bucket_name)
  16. # if not found:
  17. # client.make_bucket(bucket_name)
  18. # print(f"存储桶 {bucket_name} 已创建")
  19. # else:
  20. # print(f"存储桶 {bucket_name} 已存在")
  21. #
  22. # cloud_path = os.path.join(data_dir, object_name).replace("\\", "/")
  23. #
  24. # client.fput_object(bucket_name, cloud_path, img_path, content_type="image/jpeg")
  25. # print(f"成功上传 {object_name} 到 {bucket_name}")
  26. # except Exception as e:
  27. # print(f"发生错误: {e}")