Minor improvement to the saving of a hosted file. Guessing the content type based on the extension.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import datetime, hashlib, os, pathlib, shutil, time
|
||||
import datetime, hashlib, mimetypes, os, pathlib, shutil, time
|
||||
|
||||
from fastapi import File, UploadFile
|
||||
from typing import Dict, List, Optional, Set, Union
|
||||
@@ -441,8 +441,7 @@ async def save_file_to_hosted_file(
|
||||
|
||||
# There is a difference between Content-Type and MIME type.
|
||||
# https://stackoverflow.com/questions/3452381/whats-the-difference-of-contenttype-and-mimetype
|
||||
# file_info['content_type'] = file.content_type # might also include charset or other parameters
|
||||
# file_info['mimetype'] = file.mimetype # This may need to be filled in a different way?
|
||||
file_info['content_type'] = mimetypes.guess_type(filename)[0]
|
||||
|
||||
file_obj.seek(0, os.SEEK_END)
|
||||
file_size = file_obj.tell()
|
||||
|
||||
Reference in New Issue
Block a user