renamed module

This commit is contained in:
Brian Bjarke Jensen
2024-06-04 20:35:08 +02:00
parent 11aed4497c
commit b98234267f
5 changed files with 2 additions and 2 deletions
+30
View File
@@ -0,0 +1,30 @@
"""Definition of put function."""
from __future__ import annotations
import os
from io import BytesIO
from minio import Minio
def put(
client: Minio,
buffer: BytesIO,
object_name: str,
) -> None:
"""Put buffer in bucket in MinIO."""
assert isinstance(client, Minio)
assert isinstance(buffer, BytesIO)
assert isinstance(object_name, str)
bucket_name = os.getenv('MINIO_BUCKET_NAME', default=None)
assert isinstance(bucket_name, str)
# prepare for saving
num_bytes = buffer.tell()
buffer.seek(0)
# send data to bucket
client.put_object(
bucket_name=bucket_name,
object_name=object_name,
length=num_bytes,
data=buffer,
)