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

Add ability to post a file via the data param #194

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

justmobilize
Copy link
Collaborator

@justmobilize justmobilize commented Jun 19, 2024

Add ability to post a file via the data param

  • Broke some common functionality into reusable blocks
  • if the data object has read send it up as raw data, reading in chuncks

@justmobilize justmobilize marked this pull request as ready for review June 19, 2024 20:04
@dhalbert dhalbert requested a review from a team June 19, 2024 20:18
@jmangum
Copy link

jmangum commented Jun 24, 2024

Tested @justmobilize solution with a Pico W/OV5640 PiCowbell/PiCowbell doubler setup which posts jpeg to Adafruit IO with feed history turned-off. Works perfectly! Due to memory limitations have to reset board (I actually put it into a TimeAlarm deep sleep) after each picture acquisition and upload, but this is a small price to pay (and probably a more sensible solution for an application that one might want to run with a battery).

A couple of important implementation notes:

  1. Using 640x480 image size
  2. Could not use cam.quality less than 11 (otherwise run out of memory)

Thank you @justmobilize !

@jerryneedell
Copy link
Contributor

Is there an example for using this? I'd like to give it a try, but I'm not sure how to use it.

@jmangum
Copy link

jmangum commented Jun 24, 2024

Sure thing @jerryneedell . Attached is my test code. Very much a work-in-progress, so please excuse the awful code. It does work as I have repeatedly posted pictures to aio.
code_iotfeeder.py.txt

@justmobilize
Copy link
Collaborator Author

@jerryneedell here is the test code I used (just used an existing file): https://gist.github.com/justmobilize/f0ee9668d7aab6d91524b3ab53953d2c

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks for the new functionality @justmobilize!

Thanks for testing and letting us know @jmangum.

I tested this version successfully on a Feather ESP32S3 TFT. I compared requests made with this version of the library against those made with CPython requests using the same requests.post argument values.

All of my testing was with a local flask test server, not adafruit IO specifically.

I do think it would be nice ultimately to have an example in the repo in the examples dir, it's slightly more discoverable there than in the tests.

@FoamyGuy FoamyGuy merged commit 420c242 into adafruit:main Jun 24, 2024
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 25, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_DS248x to 1.0.1 from 1.0.0:
  > Update ds248x_simpletest.py

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 8.4.0 from 8.3.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#209 from justmobilize/add-ap-info

Updating https://github.com/adafruit/Adafruit_CircuitPython_ConnectionManager to 3.1.1 from 3.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ConnectionManager#21 from justmobilize/update-wiznet-version-check

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 3.1.2 from 3.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#208 from RetiredWizard/monoprecision

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 4.1.1 from 4.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#195 from DJDevon3/main
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#194 from justmobilize/post-file-as-data

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_S35710, Adafruit_CircuitPython_HX711

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
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

Successfully merging this pull request may close these issues.

4 participants