Download image

  • I am not able understand the example given on enginio website to download images stored on enginio

    It would be helpful if someone can help me with it

  • Lifetime Qt Champion


    You should add a link to the example you are referring to

  • "You will be able to go through links here":

    now see i am able to get how it is uploading
    but i am not able to get how is it downloading

    it will show you all the files in case you need to find something from another file
    sorry for so many files

  • Lifetime Qt Champion

    By download, do you mean showing the images in the list view ? From a quick look at the doc, the heavy lifting is done in the EnginioModel

  • well i am basically not able to get the query that is being done to get the image
    plus im interested in storing the image in QImage object so that i can show it later

  • The whole magic is written in 3 functions:
    void ImageObject::setObject(const QJsonObject &object)
    void ImageObject::replyFinished(EnginioReply *enginioReply)
    void ImageObject::downloadFinished()

    The first one is checking if the image is not a local file, if it is not then it asks for download url (aka "expiringUrl'). The 2nd function extract the url and asks for the file. The last function constructs the image from the received byte array.

  • This is what i am doing right now
    QJsonObject query;

     query.insert("objectType", QString("objects.image"));
     EnginioReply *reply=client->query(query);

    void MainWindow::showResult(EnginioReply *reply)
    qDebug()<<"Inside Result";

    QString url=reply->data().value("expiringUrl").toString();
    QNetworkRequest request(url);

    void MainWindow::downloadFinished()
    QByteArray imageData=m_reply->readAll();
    qDebug()<<m_image.isNull()<<" Check for NULL";


  • You forgot to write which part doesn't work and what is the error message.

  • oh my apologies


    no image is displayed
    the error message is "QImage::scaled: Image is a null image"

    this error comes in the same segment of code

  • Ok, have you tried to debug it? Are you sure that you are getting the right url? What kind of data the server returned? Check all replies for isError() value, try to printout all data() values.

  • no i am not getting any url
    it's empty

  • so what reply->data() returns?

  • @
    QJsonObject({"query": {"limit": 100,"query": {}},"results": [{"createdAt": "2014-01-13T14:26:41.254Z","file": {"id": "52d3f78a698b3c51a1028733","objectType": "files"},"id": "52d3f7a1698b3c623202389e","name": "file1","objectType": "objects.image","updatedAt": "2014-01-13T14:26:41.254Z"}]})

    Is it possible that the problem that i am having is because i have installed qt 5.2 offline and QtEnginio 0.6.0?

  • You should use Enginio 1.0.1 in the first place, please update your installation.

    In your reply there is no url, because you haven't ask for it, use Enginio::Client::downloadUrl method to get it.

Log in to reply

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