(Ruby) Demonstrate S3_DownloadBytes
Demonstrates how to download a file into memory from the Amazon S3 service.
require 'chilkat'
# This example assumes the Chilkat HTTP API to have been previously unlocked.
# See Global Unlock Sample for sample code.
http = Chilkat::CkHttp.new()
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.new()
success = http.S3_DownloadBytes(bucketName,objectName,jpgBytes)
if (http.get_LastMethodSuccess() != true)
print http.lastErrorText() + "\n";
exit
end
print "Download successful." + "\n";
fac = Chilkat::CkFileAccess.new()
success = fac.WriteEntireFile(localFilePath,jpgBytes)
print "File saved success = " + success.to_s() + "\n";
|