Grinding commited on
Commit
da4263f
·
verified ·
1 Parent(s): 618f8da

Update app/main.py

Browse files
Files changed (1) hide show
  1. app/main.py +3 -5
app/main.py CHANGED
@@ -20,7 +20,8 @@ app.add_middleware(
20
  )
21
 
22
  tasks = {}
23
- TEMP_DIR = Path("temp_audio")
 
24
  TEMP_DIR.mkdir(exist_ok=True)
25
 
26
  # Define allowed file extensions and max size (50MB)
@@ -42,9 +43,6 @@ async def upload_audio_file(background_tasks: BackgroundTasks, file: UploadFile
42
  )
43
 
44
  # Validation: File Size
45
- # We read the file into memory once to check size and then save it.
46
- # This is a trade-off for validation. For extremely large files (>1GB),
47
- # a streaming validator would be better, but this is fine for a 50MB limit.
48
  file_content = await file.read()
49
  if len(file_content) > MAX_FILE_SIZE:
50
  raise HTTPException(status_code=413, detail="File too large. Limit is 50MB.")
@@ -79,4 +77,4 @@ async def get_task_result(task_id: str):
79
  task = tasks.get(task_id)
80
  if not task or task.get("status") != "complete":
81
  raise HTTPException(status_code=404, detail="Result not yet available or task not found")
82
- return task.get("result")
 
20
  )
21
 
22
  tasks = {}
23
+ # --- KEY CHANGE: Use the /tmp directory which is always writable ---
24
+ TEMP_DIR = Path("/tmp/temp_audio")
25
  TEMP_DIR.mkdir(exist_ok=True)
26
 
27
  # Define allowed file extensions and max size (50MB)
 
43
  )
44
 
45
  # Validation: File Size
 
 
 
46
  file_content = await file.read()
47
  if len(file_content) > MAX_FILE_SIZE:
48
  raise HTTPException(status_code=413, detail="File too large. Limit is 50MB.")
 
77
  task = tasks.get(task_id)
78
  if not task or task.get("status") != "complete":
79
  raise HTTPException(status_code=404, detail="Result not yet available or task not found")
80
+ return task.get("result")