Use binary like png


#1

Hello,
Whats the good way to use .png file in apistar.

I saw there is a multipart codec, a download codec but I can’t make it run.
I tried the http.RequestData component like in in the tests. it’s ok with bytes but not with binary.

Does anyone one has an example to show ?
thanks
Jimmy


#2

@jgirardet

  • Are you trying to upload the png or download it?
  • If you open("some_image.png", "rb") and thus getting bytes, what exactly doesn’t work for you?
  • So far I use for upload the solution you pointed me at.
  • For download I think my best bet is to return http.Response object. But since I want to be able to download a large file, I am thinking of sub-classing Response passing a file-descriptor to its __init__(content=...) and overriding its render method to do something clever with the file-descriptor (although I am not yet sure what).

I would very much appreciate any pointers or feedback about the approach to download a file.


Download a large file w/o loading it into memory