PhilBot
PhilBot

Reputation: 60

Amazon AWS CPP SDK Get S3 Bucket Download Progress

On Linux I am using the AWS CPP SDK to download a 23 MB file from an S3 Bucket with the following code. It works great but I want to get the download progress as well. I cannot find any examples on Google. I think I need to set the "SetDataReceivedEventHandler) callback. Can anyone tell me what that function should look like / how I can implement it and register it? Thanks.

    GetObjectRequest getObjectRequest;
    getObjectRequest.SetBucket(bucket.c_str());
    getObjectRequest.SetKey(keyName.c_str());
    getObjectRequest.SetResponseStreamFactory([&destination](){
     return Aws::New<Aws::FStream>(
     "s3file", destination, std::ios_base::out); });

    // getObjectRequest.SetDataReceivedEventHandler() <--- How do I use this?

    GetObjectOutcome getObjectOutcome = SessionClient->GetObject(getObjectRequest);
    if(getObjectOutcome.IsSuccess())
    {
        std::cout << "<AWS DOWNLOAD> Get FW success!" << std::endl;
    }
    else
    {
        std::cout << "<AWS DOWNLOAD> Get FW failed: " << getObjectOutcome.GetError().GetMessage() << std::endl;
        exit(1);
    }

Upvotes: 2

Views: 1178

Answers (1)

Adam Owczarczyk
Adam Owczarczyk

Reputation: 2862

Have you tried using TransferManager ? It has download progress callbacks. Full doc link

Upvotes: 1

Related Questions