(Unicode C++) Demonstrate S3_DownloadBytes
Demonstrates how to download a file into memory from the Amazon S3 service.
#include <CkHttpW.h>
#include <CkByteData.h>
#include <CkFileAccessW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
http.put_AwsAccessKey(L"AWS_ACCESS_KEY");
http.put_AwsSecretKey(L"AWS_SECRET_KEY");
const wchar_t *bucketName = L"chilkat.qa";
const wchar_t *objectName = L"images/sea_creatures/starfish.jpg";
const wchar_t *localFilePath = L"qa_output/starfish.jpg";
CkByteData jpgBytes;
success = http.S3_DownloadBytes(bucketName,objectName,jpgBytes);
if (http.get_LastMethodSuccess() != true) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"Download successful.\n");
CkFileAccessW fac;
bool success = fac.WriteEntireFile(localFilePath,jpgBytes);
wprintf(L"File saved success = %d\n",success);
}
|