Thanks to visit codestin.com
Credit goes to github.com

Skip to content

✨ Add support for declaring UploadFile parameters without explicit File()#4469

Merged
tiangolo merged 8 commits into
masterfrom
upload-file-alone
Jan 23, 2022
Merged

✨ Add support for declaring UploadFile parameters without explicit File()#4469
tiangolo merged 8 commits into
masterfrom
upload-file-alone

Conversation

@tiangolo

Copy link
Copy Markdown
Member

✨ Add support for declaring UploadFile parameters without explicit File().

For example, this is now supported:

from fastapi import FastAPI, UploadFile

app = FastAPI()

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

This also updates UploadFile to declare its own JSON Schema, and removes the equivalent and no longer necessary utility function that did a workaround for that.

This also includes docs and tests for the variations of UploadFile.

@github-actions

Copy link
Copy Markdown
Contributor

📝 Docs preview for commit 52efd58 at: https://61eda7ca0b769244610550d0--fastapi.netlify.app

@tiangolo tiangolo enabled auto-merge (squash) January 23, 2022 19:09
@codecov

codecov Bot commented Jan 23, 2022

Copy link
Copy Markdown

Codecov Report

Merging #4469 (5f4f43f) into master (59b1f35) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            master     #4469    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          511       521    +10     
  Lines        12845     13078   +233     
==========================================
+ Hits         12845     13078   +233     
Impacted Files Coverage Δ
docs_src/request_files/tutorial001.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial001_02.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial001_02_py310.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial001_03.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial002.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial002_py39.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial003.py 100.00% <100.00%> (ø)
docs_src/request_files/tutorial003_py39.py 100.00% <100.00%> (ø)
fastapi/datastructures.py 100.00% <100.00%> (ø)
fastapi/dependencies/utils.py 100.00% <100.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59b1f35...5f4f43f. Read the comment docs.

@github-actions

github-actions Bot commented Jan 23, 2022

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot temporarily deployed to commit January 23, 2022 19:14 Inactive
@tiangolo tiangolo merged commit 1bf5520 into master Jan 23, 2022
@tiangolo tiangolo deleted the upload-file-alone branch January 23, 2022 19:14
huonw added a commit to huonw/fastapi that referenced this pull request May 2, 2022
JeanArhancet pushed a commit to JeanArhancet/fastapi that referenced this pull request Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant