[SOLVED]Enginio Query problems



  • I'm trying to do a simple Enginio query in C++ and want to return a single object given the ID. Using the same code the Remove operation works fine. However, the query returns all of the objects of that type.

    @
    void QCloudSup::smplqueryobid(const QString &objid)
    // Simple query an object id to get the associated object.
    //
    //
    //
    {
    QJsonObject query;

    query["objectType"] = QString::fromUtf8(Ufltype);
    query["id"] = QString::fromUtf8("53da10d65a3d8b56e601b871");
    
    const EnginioReply* reply=m_client->query(query);
    
    connect(reply, SIGNAL(finished(EnginioReply*)), this, SLOT(getfileObject(EnginioReply*)));
    

    }

    void QCloudSup::getfileObject(EnginioReply *reply)
    // Get file object.
    //
    //
    {
    int lflg1;
    QDateTime lastmod;

    reply->deleteLater();
    

    QString path = reply->data().value("fileName").toString();
    QString lpath = reply->data().value("localPath").toString();
    QString objectId = reply->data().value("id").toString();

    lflg1=0;

    QJsonArray results = reply->data()["results"].toArray();

    foreach (const QJsonValue &value, results)
    {
    const QJsonObject& object = value.toObject( );
    const QString& time = object["updatedAt"].toString( );
    const QString& fileName = object["fileName"].toString( );
    const QString& lpath = object["localPath"].toString( );
    const QString& objid = object["id"].toString( );

    }
    }
    @



  • You have found small inconsistency in the API, I should be fixed in a next release (https://codereview.qt-project.org/#/c/91286/).

    You can change your code to:
    @
    QJsonObject query, q;
    query["objectType"] = QString::fromUtf8(Ufltype);
    q["id"] = QString::fromUtf8("53da10d65a3d8b56e601b871");
    query["query"] = q;
    @

    that should work



  • Thanks very much for responding, your suggestion worked perfectly. However, I'm having another problem - I can upload files properly using Enginio but am having problems trying to download them. The code segment below won't return the URL properly, the url string in DLUrlDone is empty. The same thing happens in the "image-gallery" project project in the ImageObject::replyFinished method. Can you see anything wrong with my code or the image-gallery project project?

    Thanks.

    @
    void QCloudSup::DLdUrl(const QString &objid)
    {

    if (objid.isEmpty())
        return;
    
    QJsonObject object,d;
    object["id"] = objid; // ID of an existing object with attached file
    
    const EnginioReply *replyDownload = m_client->downloadUrl(object);
    
    connect(replyDownload, SIGNAL(finished(EnginioReply*)), this, SLOT(DLUrlDone(EnginioReply*)));
    

    }

    void QCloudSup::DLUrlDone(EnginioReply *reply)
    // Download URL completed.
    //
    // Notes:
    //
    {
    QString path;
    QString objectId;
    quint8 lflg1;

    lflg1=0;

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

    m_reply = m_client->networkManager()->get(request);
    // m_reply->setParent(this);
    connect(m_reply, SIGNAL(finished()), this, SLOT(downloadFinished()));
    }
    @



  • Have you tried to print out reply->data()? are you sure that reply.isError() is false?



  • Thanks but I was able to find what the problem was. I wasn't using the proper object id. I posted to another thread I created that I had found the problem but it wouldn't let me create the post to this thread. The "image-gallery" project still doesn't return the url but I'm not really concerned about that now.


Log in to reply
 

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