Spaces:
Sleeping
Sleeping
update local_storage_service.py
Browse files
src/expon/presentation/infrastructure/services/storage/local_storage_service.py
CHANGED
@@ -7,7 +7,7 @@ import shutil
|
|
7 |
class LocalStorageService:
|
8 |
def __init__(self, base_path: str = "/tmp/storage/audio"):
|
9 |
self.base_path = base_path
|
10 |
-
os.makedirs(self.base_path, exist_ok=True)
|
11 |
|
12 |
def save(self, file: UploadFile) -> str:
|
13 |
filename = f"{uuid4()}_{file.filename}"
|
@@ -16,4 +16,9 @@ class LocalStorageService:
|
|
16 |
with open(file_path, "wb") as buffer:
|
17 |
shutil.copyfileobj(file.file, buffer)
|
18 |
|
19 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
7 |
class LocalStorageService:
|
8 |
def __init__(self, base_path: str = "/tmp/storage/audio"):
|
9 |
self.base_path = base_path
|
10 |
+
os.makedirs(self.base_path, exist_ok=True)
|
11 |
|
12 |
def save(self, file: UploadFile) -> str:
|
13 |
filename = f"{uuid4()}_{file.filename}"
|
|
|
16 |
with open(file_path, "wb") as buffer:
|
17 |
shutil.copyfileobj(file.file, buffer)
|
18 |
|
19 |
+
return filename # Solo devolvemos el nombre, no toda la ruta
|
20 |
+
|
21 |
+
def delete(self, filename: str):
|
22 |
+
file_path = os.path.join(self.base_path, filename)
|
23 |
+
if os.path.exists(file_path):
|
24 |
+
os.remove(file_path)
|