Results 1 to 6 of 6

Thread: Posting images to AWS S3 with QNetworkAccessManager PUT (Android)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: Posting images to AWS S3 with QNetworkAccessManager PUT (Android)

    Quote Originally Posted by d_stranz View Post
    Network byte order is big-endian. Android is little-endian, so it is possible that your hash() call is generating a little-endian QByteArray. So try this:

    Qt Code:
    1. #include <QtEndian>
    2.  
    3. QByteArray AndroidTemp = QMessageAuthenticationCode::hash(StringToSign, SecretKey, QCryptographicHash::Sha1);
    4. QByteArray AndroidString = AndroidTemp.toBase64(); // for comparison purposes
    5.  
    6. QByteArray SignTemp( AndroidString ); // copy so the two arrays are the same size
    7. qToBigEndian( &AndroidTemp, AndroidTemp.size(), &SignTemp );
    8.  
    9. QByteArray SignString = SignTemp.toBase64();
    To copy to clipboard, switch view to plain text mode 

    Are SignString and AndroidString the same? If so, then hash() is generating a big-endian array. If not, then it is probably little-endian.
    Try sending this version of SignString to AWS
    thank you for your reply - turned out my issue with signature was caused by the double slashes in StringToSign so replacing \\n with \n solved it - I am not getting any more errors but m_reply->readAll() now returns an empty string, no errors are reported by errorOccurred signal and nothing gets posted to s3. so not sure what is wrong now

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,349
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Posting images to AWS S3 with QNetworkAccessManager PUT (Android)

    I am not getting any more errors but m_reply->readAll() now returns an empty string
    From what I read in the docs about QNetworkReply, the finished() signal is emitted after the put() request is completely done. So by the time you see that, all of the reply has been sent and there is nothing more to read.

    I think what you need to do is the handle the QIODevice::readyRead() signal and in your slot retrieve all of the pending data and put it onto the end of a buffer. Keep doing that until you receive the finished() signal, at which point you know you have received everything the server is going to send.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. how to use QNetworkAccessManager to download images in QT
    By iswaryasenthilkumar in forum Newbie
    Replies: 5
    Last Post: 6th March 2015, 09:54
  2. QNetworkAccessManager not receiving data in Android, but works in Desktop
    By kubark42 in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 23rd November 2014, 17:19
  3. Http Posting using QNetworkAccessManager
    By Mohammadhzp in forum Newbie
    Replies: 17
    Last Post: 24th January 2014, 17:00
  4. Replies: 2
    Last Post: 8th January 2014, 15:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.