| 1234567891011121314151617181920212223242526272829 |
- from minio import Minio
- client = Minio(
- "192.168.77.249:9000",
- access_key="pZEwCGnpNN05KPnmC2Yh",
- secret_key="KfJRuWiv9pVxhIMcFqbkv8hZT9SnNTZ6LPx592D4",
- secure=False
- )
- bucket_name = "grading"
- try:
- # 2. 检查存储桶是否存在
- found = client.bucket_exists(bucket_name)
- if not found:
- client.make_bucket(bucket_name)
- print(f"存储桶 {bucket_name} 已创建")
- else:
- print(f"存储桶 {bucket_name} 已存在")
- # 4. 列出该目录(桶)下的所有文件
- objects = client.list_objects(bucket_name, recursive=True)
- for obj in objects:
- print(f"对象名称: {obj.object_name}, 大小: {obj.size} bytes")
- except Exception as e:
- print(f"发生错误: {e}")
|