question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] UploadFile to bytes

See original GitHub issue

First 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:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
tiangolocommented, Jun 6, 2020

Thanks for the help here @phy25 ! 👏 🙇

Thanks for reporting back and closing the issue @INGCRENGIFO 👍

0reactions
Qleoz12commented, Oct 18, 2021

thanks, i just made it work:

image

hey do you have a sample code from this?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found