Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File uploading error #28

Closed
otsuka opened this issue Jan 20, 2020 · 5 comments · Fixed by #29
Closed

File uploading error #28

otsuka opened this issue Jan 20, 2020 · 5 comments · Fixed by #29
Assignees
Labels
bug Something isn't working

Comments

@otsuka
Copy link
Contributor

otsuka commented Jan 20, 2020

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
@masipcat
Copy link
Contributor

I'll try to fix it tonight :)

@masipcat masipcat self-assigned this Jan 21, 2020
@masipcat masipcat added the bug Something isn't working label Jan 21, 2020
@masipcat
Copy link
Contributor

Fix released on v1.4.1. Please confirm me that is working now

@otsuka
Copy link
Contributor Author

otsuka commented Jan 22, 2020

Thank you very much! 👍
I will try it later on.

@otsuka
Copy link
Contributor Author

otsuka commented Jan 22, 2020

I have confirmed that an image file can be uploaded from the TestClient.post() method 🎉

@masipcat
Copy link
Contributor

Yay! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants