(Perl) Demonstrate S3_DownloadBytes
Demonstrates how to download a file into memory from the Amazon S3 service.
use 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() != 1) {
print $http->lastErrorText() . "\r\n";
exit;
}
print "Download successful." . "\r\n";
$fac = chilkat::CkFileAccess->new();
$success = $fac->WriteEntireFile($localFilePath,$jpgBytes);
print "File saved success = " . $success . "\r\n";
|