Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Possible/How to set content type for UploadFile? #1868

Closed
7 tasks done
jeremyschiemann opened this issue Aug 10, 2020 · 1 comment
Closed
7 tasks done

Possible/How to set content type for UploadFile? #1868

jeremyschiemann opened this issue Aug 10, 2020 · 1 comment

Comments

@jeremyschiemann
Copy link

First check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.

Example

Here's a self-contained, minimal, reproducible, example with my use case:

from fastapi import FastAPI, File, UploadFile

app = FastAPI()


@app.get("/")
def file_upload(file: UploadFile = File(..., media_type='text/xml')):
    return {"Hello": "World"}

Description

The schema created for this file doesn't mention the specified media type. (see: OpenAPI 'Specifying Content-Type')
How is a application supposed to know what kind of files it can send?

I'd expect something like

encoding: {
        "file": {"contentType": "text/xml"}
}

Environment

  • OS: Windwos 10
  • FastAPI Version: 0.60.1
  • Python version: 3.8
@jeremyschiemann jeremyschiemann added the question Question or problem label Aug 10, 2020
@rkbeatss
Copy link
Contributor

See similar #1018. Looks interesting, down to work on a fix for this!

Repository owner locked and limited conversation to collaborators Feb 28, 2023
@tiangolo tiangolo converted this issue into discussion #9107 Feb 28, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants