chore: prepare repository for submodule split
This commit is contained in:
@@ -105,6 +105,24 @@ def put_file(object_path: str, data: bytes, size: int):
|
||||
return {'storage': 'local', 'path': str(local_path)}
|
||||
|
||||
|
||||
|
||||
def put_file_stream(object_path: str, source, size: int):
|
||||
bucket = MINIO_BUCKET
|
||||
try:
|
||||
source.seek(0)
|
||||
mc.put_object(bucket, object_path, source, length=size)
|
||||
return {'storage': 'minio', 'path': object_path}
|
||||
except Exception as e:
|
||||
print(f"minio put_file_stream error: {e}")
|
||||
local_path = LOCAL_UPLOAD_ROOT / object_path
|
||||
local_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
source.seek(0)
|
||||
with open(local_path, 'wb') as target:
|
||||
shutil.copyfileobj(source, target, length=1024 * 1024)
|
||||
print(f"local fallback stored {local_path}")
|
||||
return {'storage': 'local', 'path': str(local_path)}
|
||||
|
||||
|
||||
def remove_prefix(prefix: str):
|
||||
bucket = MINIO_BUCKET
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user