How do I create an Aws::Utils::ByteBuffer from QString for AWS C++ SDK?



  • I'm new to C++ and QT, working with the AWS C++ SDK, the Kinesis PutRecordRequest requires a data property (the message). It takes a Aws::Utils::ByteBuffer. I'm having trouble understanding how to create this from a QString.


  • Lifetime Qt Champion

    Hi
    What is Aws::Utils::ByteBuffer ?
    Seems to be
    Array<unsigned char> Aws::Utils::ByteBuffer
    So you could loop the string and add to such Array.



  • @mrjj said in How do I create an Aws::Utils::ByteBuffer from QString for AWS C++ SDK?:

    Array<unsigned char>

    Yes, it appears that's what it is. Could I bother you for an example on this?



  • I believe I've got it.
    included

    and then

    typedef Aws::Utils::Array<unsigned char> ByteBuffer;
    ...
    Aws::String streamName = "qt";
    QString myMessage = "The Message";
    Aws::Kinesis::KinesisClient kinesis;
    Aws::Kinesis::Model::PutRecordRequest k_req;
    k_req.SetStreamName(streamName);
    k_req.SetPartitionKey("123");
    k_req.SetData(ByteBuffer((unsigned char *)myMessage.toStdString().c_str(),myMessage.length()));
    auto k_out = kinesis.PutRecord(k_req);
    ...
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.