INNER CODE UNIT · Python
upload_file
iamgreggarcia/codesherpa · localserver/main.py:120
async def upload_file(file: UploadFile = File(...)):
"""
Upload a file.
Args:
file (UploadFile): The uploaded file.
Returns:
dict: The result of the file upload process.
"""
try:
print('trying to upload file: ', file.filename)
file_location = f"static/uploads/{file.filename}"
# Create directories if they do not exist
os.makedirs(os.path.dirname(file_location), exist_ok=True)
with open(file_location, "wb") as buffer: