Reputation: 323
I am trying to download a .zip file from AWS S3 using boto code, however getting following error:
'str' object has no attribute 'write'
code
s3Conn = S3Connection(aws_access_key_id='ABCD',
aws_secret_access_key='xyz')
s3bucket = s3Conn.get_bucket(mybucket)
key = s3bucket.new_key("2015/02/20/TestFile.zip")
try:
key.get_contents_to_file(backupdir)
except:
print("{0}".format(sys.exc_info()))
Upvotes: 0
Views: 1356
Reputation: 323
def downloadBackupFile(backupdir):
key = s3bucket.new_key("2015/02/20/TestFile.zip")
try:
if (os.path.exists(backupdir)):
key.get_contents_to_file(open(backupdir + "TestFile.zip", "w+"))
except:
print("{0}".format(sys.exc_info()))
Upvotes: 0
Reputation: 60065
I assume backupdir
is string but boto expects file object (like open(backupdir)
)
Upvotes: 2