Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions python/example_code/s3/s3_basics/presigned_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ def usage_demo():
response = None
if args.action == "get":
response = requests.get(url)
if response.status_code == 200:
with open(args.key.split("/")[-1], 'wb') as object_file:
object_file.write(response.content)
elif args.action == "put":
print("Putting data to the URL.")
try:
with open(args.key, "r") as object_file:
with open(args.key, "rb") as object_file:
object_text = object_file.read()
response = requests.put(url, data=object_text)
except FileNotFoundError:
Expand All @@ -83,9 +86,7 @@ def usage_demo():
)

if response is not None:
print("Got response:")
print(f"Status: {response.status_code}")
print(response.text)
print(f"Status: {response.status_code}\nReason: {response.reason}")

print("-" * 88)

Expand Down
Loading