File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
python/example_code/s3/s3_basics Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments