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

"blob" is missing from aio.ajax's format #1475

Closed
goffi-contrib opened this issue Aug 26, 2020 · 2 comments
Closed

"blob" is missing from aio.ajax's format #1475

goffi-contrib opened this issue Aug 26, 2020 · 2 comments

Comments

@goffi-contrib
Copy link
Contributor

goffi-contrib commented Aug 26, 2020

Hello,

It is not currently (as of Brython 3.8.9) possible to request a Blob response format when using aio.ajax method. This is a problem when we want to fetch a file, and binary is not a good alternative, specially if we want to upload the fetched field using an other ajax request (which is my use case).

I would like to be able to do something like that, and that doesn't seem possible with current aio module:

r = await aio.get(some_url, format="blob")
blob = r.data
# some processing…
await aio.ajax("PUT", some_other_url, data=blob)

aio module is nice to avoid callbacks hell that we would have with blocking browser.ajax

Thanks!

note: maybe I've missed something with the binary format, but it seems that we can't use it to send binary data, as aio.ajax expects a str or a dict according to doc.

@PierreQuentel
Copy link
Contributor

I have fixed the issue by allowing to send bytes in the argument data of POST or PUT requests.

@goffi-contrib
Copy link
Contributor Author

@PierreQuentel Hello, thanks for that. I guess that works too, but what if we get a blob, is there a way to convert a JS blob to Brython bytes? Does using bytes has an impact on performances (memory or CPU)? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants