added support for content type when putting object in minio
This commit is contained in:
@@ -113,13 +113,15 @@ class MinioAdapter(
|
||||
self.logger.debug(res)
|
||||
return res
|
||||
|
||||
def _put(self, object_name: str, data: BytesIO) -> None:
|
||||
def _put(self, object_name: str, data: BytesIO, content_type: str = "application/octet-stream") -> None:
|
||||
"""Put an object into the Minio bucket."""
|
||||
# Check input
|
||||
if not isinstance(object_name, str) or len(object_name) == 0:
|
||||
raise ValueError("object_name must be a non-empty string")
|
||||
if not isinstance(data, BytesIO) or data.getbuffer().nbytes == 0:
|
||||
raise ValueError("data must be a non-empty BytesIO object")
|
||||
if not isinstance(content_type, str) or len(content_type) == 0:
|
||||
raise ValueError("content_type must be a non-empty string")
|
||||
# Check connection
|
||||
if self._client is None or not self.is_connected:
|
||||
raise ConnectionError("Not connected to Minio")
|
||||
@@ -134,6 +136,7 @@ class MinioAdapter(
|
||||
data=data,
|
||||
length=num_bytes,
|
||||
part_size=self.chunk_size,
|
||||
content_type=content_type,
|
||||
)
|
||||
self.logger.debug(
|
||||
f"Put object '{object_name}' into bucket '{self._bucket_name}'"
|
||||
|
||||
Reference in New Issue
Block a user