-
Notifications
You must be signed in to change notification settings - Fork 35
Files arg #189
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
Merged
Merged
Files arg #189
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
77f8b95
starting files arg for uploading
FoamyGuy e4646a5
cleanup, lint, format
FoamyGuy ad7aaca
example file for upload
FoamyGuy c583e0f
Update files to chunk
justmobilize 8a14e8d
Add tests
justmobilize d5614b2
Fix test file name
justmobilize a2b43ac
Update example to match others
justmobilize 913c4c8
remove files test for now
FoamyGuy c701ab7
Merge pull request #2 from FoamyGuy/files_arg_plus_foamyguy
FoamyGuy 7c8d2b2
Add tests
justmobilize 1eaa1a8
Use actual content length too
justmobilize 9b9f7bc
move requests to optional. change copyright name in new test file. ad…
FoamyGuy a8b78ad
Merge pull request #3 from justmobilize/files_arg_tests
FoamyGuy 5a2934e
use os.urandom()
FoamyGuy 0f9b71f
Remove str concatenation
justmobilize 55f159f
Merge pull request #4 from justmobilize/files_arg_no_str_concat
FoamyGuy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
import adafruit_connection_manager | ||
import wifi | ||
|
||
import adafruit_requests | ||
|
||
URL = "https://httpbin.org/post" | ||
|
||
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio) | ||
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio) | ||
requests = adafruit_requests.Session(pool, ssl_context) | ||
|
||
with open("requests_wifi_file_upload_image.png", "rb") as file_handle: | ||
files = { | ||
"file": ( | ||
"requests_wifi_file_upload_image.png", | ||
file_handle, | ||
"image/png", | ||
{"CustomHeader": "BlinkaRocks"}, | ||
), | ||
"othervalue": (None, "HelloWorld"), | ||
} | ||
|
||
with requests.post(URL, files=files) as response: | ||
print(response.content) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions
2
examples/wifi/expanded/requests_wifi_file_upload_image.png.license
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SPDX-FileCopyrightText: 2024 Tim Cocks | ||
# SPDX-License-Identifier: CC-BY-4.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: Unlicense | ||
|
||
requests |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SPDX-FileCopyrightText: 2024 Justin Myers | ||
# SPDX-License-Identifier: Unlicense |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SPDX-FileCopyrightText: 2024 Justin Myers | ||
# SPDX-License-Identifier: Unlicense |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.