question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] Fileupload failed.

See original GitHub issue

Description

I’ve tried a sample code for upload my file but it failed.

from fastapi import FastAPI, File, UploadFile

app = FastAPI()


@app.post("/files/")
async def create_file(file: bytes = File(...)):
    return {"file_size": len(file)}


@app.post("/uploadfile/")
async def create_upload_file(file: UploadFile = File(...)):
    return {"filename": file.filename}

Result error

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

7reactions
davidefioccocommented, Dec 8, 2020

@amanjazari

It’s worth checking if you have python-multipart installed in your environment.

Via pip install python-multipart you will install the package and this may well solve your issue.

EDIT: This tip is also present in the official docs now: https://fastapi.tiangolo.com/tutorial/request-files/

5reactions
tiangolocommented, Dec 8, 2020

The latest versions (for quite a while now) detect if you use something that would require python-multipart and error out quickly giving you instructions about how to fix it.

Also, @whillas, that’s not the way to ask. I’m giving you this for free, working on it in my free time. And everyone here is helping in their free time mostly. Please try to be more respectful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error with file upload question. - Microsoft Community Hub
Hi, how to resolve this error... i unable to edit it as it grey out . error message "There's a problem with the...
Read more >
Error "File upload failed - IBM
Problem. Attempting to upload an attachment to an artifact in Engineering Test Management (ETM) using Microsoft Edge throws the error:.
Read more >
Why did my upload fail? - Acceptd - Support
To solve this problem, simply try uploading the file again! If you are exporting your videos with iMovie. We recommend selecting the quality...
Read more >
File upload failed - coursera.support
Unable to upload a pdf of my assignment multiple attempts via Chrome (also tried Safari). Cleared cache, no firewall, internet connection is ...
Read more >
Google Forms Failed to create file upload question
In google forms when I try to make a question that requires users to upload a file I get an error and it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found