Mbonea commited on
Commit
70889e0
·
1 Parent(s): d865593

faster upload?

Browse files
App/Transcription/TranscriptionRoutes.py CHANGED
@@ -26,8 +26,14 @@ async def create_file(
26
  contents = await file.read()
27
 
28
  # Write the file to disk asynchronously
29
- async with aiofiles.open(file.filename, "wb") as f:
30
- await f.write(contents)
 
 
 
 
 
 
31
 
32
  # celery task
33
  task = transcription_task.delay(file.filename, model)
 
26
  contents = await file.read()
27
 
28
  # Write the file to disk asynchronously
29
+ try:
30
+ async with aiofiles.open(file.filename, "wb") as f:
31
+ while contents := await file.read(1024 * 1024):
32
+ await f.write(contents)
33
+ except Exception:
34
+ return {"message": "There was an error uploading the file"}
35
+ finally:
36
+ await file.close()
37
 
38
  # celery task
39
  task = transcription_task.delay(file.filename, model)