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
Regular Contributor
JohnQtQml
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

    }

});

Please use plain text.
Developer
ekke
Posts: 1,440
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
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
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
markwilcox
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.

 

Please use plain text.