feat: Add .env.example configuration file and integrate Redis service into Docker Compose for improved task management. Update desktop application to support document indexing and extraction workflows, enhancing user experience with a new extraction wizard and stepper components. Revise README and documentation for clarity on setup and usage.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Helpers para subidas temporales desde la app desktop."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
from contextlib import contextmanager
|
||||
from typing import Iterator
|
||||
|
||||
from fastapi import UploadFile
|
||||
|
||||
|
||||
@contextmanager
|
||||
def temp_upload_path(upload: UploadFile, *, suffix: str | None = None) -> Iterator[str]:
|
||||
"""Guarda un UploadFile en disco temporal y lo elimina al salir."""
|
||||
ext = suffix
|
||||
if ext is None and upload.filename:
|
||||
_, ext = os.path.splitext(upload.filename)
|
||||
if not ext:
|
||||
ext = ".bin"
|
||||
|
||||
fd, path = tempfile.mkstemp(suffix=ext)
|
||||
os.close(fd)
|
||||
try:
|
||||
upload.file.seek(0)
|
||||
with open(path, "wb") as handle:
|
||||
while True:
|
||||
chunk = upload.file.read(1024 * 1024)
|
||||
if not chunk:
|
||||
break
|
||||
handle.write(chunk)
|
||||
yield path
|
||||
finally:
|
||||
try:
|
||||
os.unlink(path)
|
||||
except OSError:
|
||||
pass
|
||||
Reference in New Issue
Block a user