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.

File uploading error

See original GitHub issue

I’d like to test uploading files to API server. Using your test client, I wrote the test as below:

with (datadir / "image.png").open("rb") as fp:
    files = {"image": ("sample.png", fp, "image/png")}
    response = await client.post("/api/upload_image", files=files)

But multipart file handling seems to have some error. I don’t think that decoding binary data of a file into str is possible.

        if isinstance(value, bytes):
>           value = value.decode("ascii")
E           UnicodeDecodeError: 'ascii' codec can't decode byte 0x89 in position 0: ordinal not in range(128)

../../../../../.venv/lib/python3.7/site-packages/async_asgi_testclient/multipart.py:59: UnicodeDecodeError

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
masipcatcommented, Jan 21, 2020

I’ll try to fix it tonight 😃

0reactions
masipcatcommented, Jan 22, 2020

Yay! 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Messages Explained - Manual - PHP
The error code can be found in the error segment of the file array that is created during the file upload by PHP....
Read more >
Common uploading errors - YouTube Help - Google Support
If you're having problems uploading your video, select the error message you're seeing and follow the troubleshooting steps to solve your issue.
Read more >
How to Solve File Upload Errors in Google Drive - MakeUseOf
How to Solve File Upload Errors in Google Drive: 8 Quick Solutions · 1. Check Google Drive's Status · 2. Check Your Network...
Read more >
How to access error code associated with file upload in PHP
How to access error code associated with file upload in PHP ?
Read more >
Problems with uploading files - IBM
When you are submitting a request through the Web Gateway to upload a file, you might receive an HTTP error code and a...
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