Node.js
Node.js
Demonstrate S3_DownloadBytes
Demonstrates how to download a file into memory from the Amazon S3 service.Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
http.AwsAccessKey = "AWS_ACCESS_KEY";
http.AwsSecretKey = "AWS_SECRET_KEY";
var bucketName = "chilkat.qa";
var objectName = "images/sea_creatures/starfish.jpg";
var localFilePath = "qa_output/starfish.jpg";
jpgBytes = http.S3_DownloadBytes(bucketName,objectName);
if (http.LastMethodSuccess !== true) {
console.log(http.LastErrorText);
return;
}
console.log("Download successful.");
var fac = new chilkat.FileAccess();
success = fac.WriteEntireFile(localFilePath,jpgBytes);
console.log("File saved success = " + success);
}
chilkatExample();