phase 5
This commit is contained in:
@@ -28,6 +28,14 @@ class StorageClient:
|
||||
self.bucket = settings.MINIO_BUCKET
|
||||
self._ensure_bucket_exists()
|
||||
|
||||
def put_object(self, bucket_name: str, object_name: str, data: BinaryIO, length: int, content_type: str):
|
||||
"""MinIO-compatible put_object method."""
|
||||
return self.upload_file(data, object_name, content_type)
|
||||
|
||||
def remove_object(self, bucket_name: str, object_name: str):
|
||||
"""MinIO-compatible remove_object method."""
|
||||
return self.delete_file(object_name)
|
||||
|
||||
def _ensure_bucket_exists(self) -> None:
|
||||
"""Create bucket if it doesn't exist."""
|
||||
try:
|
||||
@@ -116,3 +124,19 @@ class StorageClient:
|
||||
|
||||
# Global storage client instance
|
||||
storage_client = StorageClient()
|
||||
|
||||
|
||||
def get_storage_client() -> StorageClient:
|
||||
"""Get the global storage client instance."""
|
||||
return storage_client
|
||||
|
||||
|
||||
# Compatibility methods for MinIO-style API
|
||||
def put_object(bucket_name: str, object_name: str, data: BinaryIO, length: int, content_type: str):
|
||||
"""MinIO-compatible put_object method."""
|
||||
storage_client.upload_file(data, object_name, content_type)
|
||||
|
||||
|
||||
def remove_object(bucket_name: str, object_name: str):
|
||||
"""MinIO-compatible remove_object method."""
|
||||
storage_client.delete_file(object_name)
|
||||
|
||||
Reference in New Issue
Block a user