(C#) Demonstrate S3_DownloadBytes
Demonstrates how to download a file into memory from the Amazon S3 service.
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Chilkat.Http http = new Chilkat.Http();
http.AwsAccessKey = "AWS_ACCESS_KEY";
http.AwsSecretKey = "AWS_SECRET_KEY";
string bucketName = "chilkat.qa";
string objectName = "images/sea_creatures/starfish.jpg";
string localFilePath = "qa_output/starfish.jpg";
byte[] jpgBytes = null;
jpgBytes = http.S3_DownloadBytes(bucketName,objectName);
if (http.LastMethodSuccess != true) {
Debug.WriteLine(http.LastErrorText);
return;
}
Debug.WriteLine("Download successful.");
Chilkat.FileAccess fac = new Chilkat.FileAccess();
bool success = fac.WriteEntireFile(localFilePath,jpgBytes);
Debug.WriteLine("File saved success = " + Convert.ToString(success));
|