amazon s3 – AWS SDK S3 GetObjectAsync crashes with ResponseStream in Unreal Engine – how to fix?

I’m using AWS SDK for C++ (v1.9+) in Unreal Engine to download files from S3, but I keep getting crashes in aws_cpp_sdk_core!Aws::Utils::Stream::ResponseStream::ReleaseStream()

Here’s my exact code:

bool AWSBucketOperations::GetObjectAsync(
        const S3Client& ClientObject,
        const Aws::String& objectKey,
        const Aws::String& fromBucket,
        const Aws::String& outputFilePath,
        const std::function& callback)
    {
        Aws::S3::Model::GetObjectRequest Request;
        Request.SetBucket(fromBucket);
        Request.SetKey(objectKey);
    
        Request.SetResponseStreamFactory([=]()
        {
            return Aws::New<:fstream>(
                "S3DownloadTag",
                outputFilePath,
                std::ios_base::out | std::ios_base::binary
            );
        });
        
        ClientObject->GetObjectAsync(Request,
            [callback](
                const Aws::S3::S3Client*,
                const Aws::S3::Model::GetObjectRequest&,
                const Aws::S3::Model::GetObjectOutcome& outcome,
                const std::shared_ptr&)
            {
                if (outcome.IsSuccess()) {
                    callback(outcome);
                } else {
                    callback(outcome);
                }
            });
    
        return true;
    }

Read more here: Source link