[QUESTION] UploadFile to bytes
See original GitHub issueFirst check
- 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.
Description
Hello, I have the next function
async def add_data (files: List [UploadFile] = File (...), params: str = Form (...)):
Since this function I sent to send a message to a sengrid, then I do:
"for file in files:"
but when I do:
attachment.file_content = FileContent (file)
I got an error, I could ask for the file on base64 but
encoded = base64.b64decode (file)
it doesn’t work, thank you if you can guide me
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Cannot convert UploadFile to bytearray - Stack Overflow
Since you're expecting the file content, you can call .read() on the UploadFile object. It's a file-like object, so file.read() will give ...
Read more >Request Files - FastAPI
Use File , bytes , and UploadFile to declare files to be uploaded in the request, sent as form data. Previous Form Data...
Read more >Upload Files in Chunks , Interval Problem - LeetCode Discuss
I came across a problem in code signal where they have given bytes received in form of intervals , like if 2-4 t...
Read more >Why is my uploaded file 0 bytes? | Media Temple Community
There was most likely a problem with the upload. There are a few common causes for uploaded files to read as 0 bytes...
Read more >Solved Upload answer sheets i. Consider a disk with block
Question : Upload answer sheets i. Consider a disk with block size B = 2048 bytes. A file has r = 30,000 Faculty...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the help here @phy25 ! 👏 🙇
Thanks for reporting back and closing the issue @INGCRENGIFO 👍
hey do you have a sample code from this?