Chilkat2-Python
Chilkat2-Python
Demonstrate S3_DownloadBytes
Demonstrates how to download a file into memory from the Amazon S3 service.Chilkat Chilkat2-Python Downloads
import sys
import chilkat2
success = False
# This example assumes the Chilkat HTTP API to have been previously unlocked.
# See Global Unlock Sample for sample code.
http = chilkat2.Http()
http.AwsAccessKey = "AWS_ACCESS_KEY"
http.AwsSecretKey = "AWS_SECRET_KEY"
bucketName = "chilkat.qa"
objectName = "images/sea_creatures/starfish.jpg"
localFilePath = "qa_output/starfish.jpg"
# jpgBytes is a memoryview
jpgBytes = http.S3_DownloadBytes(bucketName,objectName)
if (http.LastMethodSuccess != True):
print(http.LastErrorText)
sys.exit()
print("Download successful.")
fac = chilkat2.FileAccess()
success = fac.WriteEntireFile(localFilePath,jpgBytes)
print("File saved success = " + str(success))