Closed jmangum closed 2 years ago
Multipart/MIME file uploads and downloads aren't available yet, but I'll look into adding that as an enhancement this week.
Perfect. FYI, the application where I would like to use file transfer over http is a wifi-connected Adafruit MLX90640 IR camera connected to an Unexpected Maker FeatherS2 ESP32S2 that I want to run as a remote wildlife camera. I may also try sending the IR camera frames over RFM95 radio transceiver, but I thought that sending over wifi might be an easier implementation.
@jmangum - are you planning to get the raw byte array from the camera driver, and then convert & send the file in-memory? That's the approach I'm looking at right now at least - providing a method to return a raw byte array with a supplied MIME type.
I was planning on using the CircuitPython library to grab the image from the camera and send these image data as a file that I could then transfer via HTTP. Did not plan on doing this in memory.
Could you point me to the library methods you were thinking of using to fetch the image? I'd like to review the return types and build an example & tests that match your use case.
The CurcuitPython library I use to read the MLX90640 is located at https://github.com/adafruit/Adafruit_CircuitPython_MLX90640.
Sure, but that seems to return a collection of integer values for infrared intensity rather than an image, correct? What functions would you call to return an image?
Correct. I can export this list of floats to a file which I can then transfer using your library. I then use another python script to generate an image from the list of floats (temperatures). This was why my original suggestion was that the general ability to transfer files would be useful.
Ah - gotcha. Thx for explaining @jmangum
For that particular use case I'd recommend serializing your floats into a JSON or plaintext response, then sending that response instead of sending a file. You could easily do that today using the Content-Type application/json
or text/plain
- you could either use the built-in JSON libraries within Python to convert an in-memory object, or you could manually build a string and send that in plaintext if you like.
I'm still going to work in allowing you to send binary data as a response (e.g. b'1234'), but for your particular use case I think you can get rolling with the current release.
@jmangum - I have a test version of ampule available in the pull request linked to this issue - feel free to try it out and let me know if that works. You will need to set the Content-Type
accordingly if you output bytes instead of a string.
Thank you @deckerego! I will give this new feature a try, but it might be a few weeks before I can get to it.
@jmangum - an updated version has been pushed to the file_download
branch with fixes for the ESP32-S2. Feel free to give the updated version a whirl.
Thank you @deckerego. I think that you can close this issue.
Rather than just sending a string response to an http request I would like to send a file from an ESP32S2 board that I am running CircuitPython and ampule on. If it is possible to do this, can you tell me how? Thanks.