How to post a UploadFile object
#9178
-
First Check
Commit to Help
Example Codefrom fastapi import UploadFile, FastAPI
from typing import Dict
import requests
app = FastAPI()
@app.post("/post_file/")
def post_file(file: UploadFile) -> Dict:
contents = file.file.read()
response = requests.post('https://example.com/post_file, files={'file': contents})
return {'response': response}DescriptionHi! How do I take a posted I have been trying to get a posted I tried to use the I'd prefer not to have to write the file and then reread it to send it, but if that's the only way I can do this, I can work with that. Operating SystemLinux, macOS Operating System DetailsNo response FastAPI Version0.89.1 Python VersionPython 3.8.16 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I got it working. For future reference if anyone else finds this: |
Beta Was this translation helpful? Give feedback.
I got it working.
For future reference if anyone else finds this: