Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image uploaded without a ContentType raises a 500 #46

Open
joelvdavies opened this issue Oct 15, 2024 · 1 comment
Open

Image uploaded without a ContentType raises a 500 #46

joelvdavies opened this issue Oct 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@joelvdavies
Copy link
Collaborator

Found while attempting to upload the generate_mock_data.py script using the requests python module in #45. See https://stackoverflow.com/questions/76647047/content-type-is-different-when-sending-file-to-fastapi-backend-using-curl-than-p. FastAPI is guessing the appropriate content type whereas requests does not. The frontend will likely guess it too, but the error should be handled more gracefully to give an appropriate error message instead. Example reproduction code:

    with open("test/files/image.jpg", mode="rb") as file:
        image = requests.post(
            f"{API_URL}/images",
            data={
                "entity_id": "65df5ee771892ddcc08bd28f",
            },
            files={"upload_file": file},
            timeout=5,
        ).json()
@joelvdavies joelvdavies added the bug Something isn't working label Oct 15, 2024
@joelvdavies
Copy link
Collaborator Author

Possibly fixed by #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant