Sample code for 30+ languages & platforms
C++

Demonstrate S3_DownloadBytes

Demonstrates how to download a file into memory from the Amazon S3 service.

Chilkat C++ Downloads

C++
#include <CkHttp.h>
#include <CkByteData.h>
#include <CkFileAccess.h>

void ChilkatSample(void)
    {
    bool success = false;

    //  This example assumes the Chilkat HTTP API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    CkHttp http;

    http.put_AwsAccessKey("AWS_ACCESS_KEY");
    http.put_AwsSecretKey("AWS_SECRET_KEY");

    const char *bucketName = "chilkat.qa";
    const char *objectName = "images/sea_creatures/starfish.jpg";
    const char *localFilePath = "qa_output/starfish.jpg";

    CkByteData jpgBytes;

    success = http.S3_DownloadBytes(bucketName,objectName,jpgBytes);
    if (http.get_LastMethodSuccess() != true) {
        std::cout << http.lastErrorText() << "\r\n";
        return;
    }

    std::cout << "Download successful." << "\r\n";

    CkFileAccess fac;
    success = fac.WriteEntireFile(localFilePath,jpgBytes);
    std::cout << "File saved success = " << success << "\r\n";
    }