Skip to content

Commit 72029a7

Browse files
authored
Update presigned_url.py
1 parent 84ba3d8 commit 72029a7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

python/example_code/s3/s3_basics/presigned_url.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@ def usage_demo():
7070
response = None
7171
if args.action == "get":
7272
response = requests.get(url)
73+
if response.status_code == 200:
74+
with open(args.key, 'wb') as object_file:
75+
object_file.write(response.content)
7376
elif args.action == "put":
7477
print("Putting data to the URL.")
7578
try:
76-
with open(args.key, "r") as object_file:
79+
with open(args.key, "rb") as object_file:
7780
object_text = object_file.read()
7881
response = requests.put(url, data=object_text)
7982
except FileNotFoundError:
@@ -83,9 +86,7 @@ def usage_demo():
8386
)
8487

8588
if response is not None:
86-
print("Got response:")
8789
print(f"Status: {response.status_code}")
88-
print(response.text)
8990

9091
print("-" * 88)
9192

0 commit comments

Comments
 (0)