Stream RAW saves with live progress v0.8.3
This commit is contained in:
1 parent
2dee67021e
commit
f1704c9822
6 files changed
+85
-27
No files matched your search
+10
-4
@@ -21,7 +21,7 @@ from typing import Annotated, Any
|
||||
|
||||
from fastapi import FastAPI, File, Form, HTTPException, Request, UploadFile
|
||||
from pydantic import BaseModel, Field
|
||||
from fastapi.responses import FileResponse, Response
|
||||
from fastapi.responses import FileResponse, Response, StreamingResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from PIL import Image, ImageOps, UnidentifiedImageError
|
||||
|
||||
@@ -85,7 +85,7 @@ APP_SUBTITLE = (
|
||||
or f"Local folder · in-place {ENABLED_FORMAT_LABEL} metadata"
|
||||
)
|
||||
APP_URL = os.getenv("APP_URL", "http://localhost:8080")
|
||||
APP_VERSION = "0.8.2"
|
||||
APP_VERSION = "0.8.3"
|
||||
MAX_UPLOAD_MB = int(os.getenv("MAX_UPLOAD_MB", "150"))
|
||||
MAX_UPLOAD_BYTES = MAX_UPLOAD_MB * 1024 * 1024
|
||||
PREVIEW_MAX_EDGE = int(os.getenv("PREVIEW_MAX_EDGE", "2400"))
|
||||
@@ -1043,11 +1043,17 @@ async def process_photo(
|
||||
response_read_seconds,
|
||||
)
|
||||
|
||||
return Response(
|
||||
content=updated_bytes,
|
||||
def response_chunks() -> Any:
|
||||
chunk_size = 256 * 1024
|
||||
for offset in range(0, len(updated_bytes), chunk_size):
|
||||
yield updated_bytes[offset:offset + chunk_size]
|
||||
|
||||
return StreamingResponse(
|
||||
response_chunks(),
|
||||
media_type=MEDIA_TYPES[suffix],
|
||||
headers={
|
||||
"Content-Disposition": f'inline; filename="{Path(filename).name}"',
|
||||
"Content-Length": str(len(updated_bytes)),
|
||||
"Cache-Control": "no-store",
|
||||
"X-Date-Precision": precision_label,
|
||||
"Server-Timing": (
|
||||
|
||||
Reference in new issue
Block a user