Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Regular Contributor
Posts: 55
Registered: ‎10-31-2012
My Device: Blackberry 10 Dev Alpha Simulator - VMware
My Carrier: (none)

How to make an http post request that uploads both post queries & a file to a server in C++ QT

I have sample code for doing this in C#, Windows Phone 7, Silverlight, and I'm trying to find how to do the equivalent in C++ QT (I am working in the Blackberry 10 Beta 3 SDK). Can I use QNetworkAccessManager? or is there something better for this? I would appreciated some help on how to do this and some sample code if you can. Here is the sample C# code:

 

var request = newRestRequest(url,Method.POST);

request.AddParamater("example","example");

request.AddParamater("example2","example2");

request.AddFile("file", fileData, filename,"image/pjpeg");

 

RestSharp.RestClient restClient = new RestClient();

 

restClient.ExecuteAsync(request,(response)=> {

    if(response.StatusCode==HttpStatusCode.OK){

        //upload successful}else{//error occured durring upload}

    }else{

        //error occured durring upload

    }

});

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: How to make an http post request that uploads both post queries & a file to a server in C++ QT

you should use the QNetworkAccessManager

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 51
Registered: ‎11-23-2012
My Device: BB10 Dev Alpha
My Carrier: GiffGaff

Re: How to make an http post request that uploads both post queries & a file to a server in C++ QT

You should also be able to do this from your QML in JavaScript with XMLHttpRequest.  I've verified that this works for simple POST data but haven't tried uploading a file.