This commit is contained in:
2022-03-05 22:43:05 +03:00
parent 32c80d58a5
commit ef013cc28a
2 changed files with 9 additions and 3 deletions

View File

@@ -65,11 +65,14 @@ async def cache_file(book: Book, file_type) -> Optional[CachedFile]:
await temp_file.write(chunk)
await temp_file.seek(0)
upload_data = await upload_file(cast(SpooledTemporaryFile, temp_file.file), filename, caption)
await response.aclose()
await client.aclose()
upload_data = await upload_file(cast(SpooledTemporaryFile, temp_file.file), filename, caption)
if upload_data is None:
return None
return await CachedFile.objects.create(
object_id=book.id, object_type=file_type, data=upload_data.data
)