(CkPython) Demonstrate S3_DownloadBytes
Demonstrates how to download a file into memory from the Amazon S3 service.
import sys
import chilkat
# This example assumes the Chilkat HTTP API to have been previously unlocked.
# See Global Unlock Sample for sample code.
http = chilkat.CkHttp()
http.put_AwsAccessKey("AWS_ACCESS_KEY")
http.put_AwsSecretKey("AWS_SECRET_KEY")
bucketName = "chilkat.qa"
objectName = "images/sea_creatures/starfish.jpg"
localFilePath = "qa_output/starfish.jpg"
jpgBytes = chilkat.CkByteData()
success = http.S3_DownloadBytes(bucketName,objectName,jpgBytes)
if (http.get_LastMethodSuccess() != True):
print(http.lastErrorText())
sys.exit()
print("Download successful.")
fac = chilkat.CkFileAccess()
success = fac.WriteEntireFile(localFilePath,jpgBytes)
print("File saved success = " + str(success))
|