from datetime import timedelta from minio import Minio # MinIO 客户端初始化 minio_client = Minio( "ai.ronsunny.cn:9000", access_key="minioadmin", secret_key="minioadmin", region="Chengdu", secure=True, ) def push_file(bucket_name, object_name, file_bytes, contents, content_type): minio_client.put_object( bucket_name, object_name, file_bytes, length=len(contents), content_type=content_type, ) def get_upload_token(bucket_name, object_name, xpires=timedelta(hours=1)): upload_url = minio_client.presigned_put_object( bucket_name=bucket_name, object_name=object_name, expires=xpires ) return {"upload_url": upload_url, "object_name": object_name} def get_temp_url(bucket_name, object_name): return minio_client.presigned_get_object( bucket_name, object_name, expires=timedelta(seconds=3600) )