Search code examples
amazon-s3awss3transfermanageraws-sdk-cpp

AWS-SDK-CPP: Transfer Manager file download crashes


The following code written in C++ on Visual Studio 2015 crashes. I am using v 1.1.1 for AWSSDKCPP-Trasnfer through NuGet. I could not find any sample code over the net or proper documentation for using transfer manager with C++ SDK. If there is a mistake on my part please point me to it.

// download a single file from aws s3 bucket
// use transfer manager
// assume Aws::InitAPI() has already been called
int downloadFile(const Aws::String &bucketName, const Aws::String &objectKey) {

    auto s3Client = Aws::MakeShared<Aws::S3::S3Client>(S3_CLIENT_TAG);
    TransferManagerConfiguration transferConfig;
    transferConfig.s3Client = s3Client;

    // lambda for download progress callback
    transferConfig.downloadProgressCallback =
        [](const TransferManager*, const TransferHandle& handle)
    { std::cout << handle.IsMultipart() << std::endl; };

    // the fabled transfer manager
    TransferManager transferManager(transferConfig);
    auto transferHandle = transferManager.DownloadFile(bucketName, "sample.txt", "sample.txt");
    transferHandle->WaitUntilFinished();    // block calling thread until download complete
    return 0;
}

Solution

  • No, there's no mistake on your part. This is a issue #574. A fix is in the pipeline. Should be released shortly.