Upload Image - NetworkRequest

1821
5
Jump to solution
12-28-2016 09:12 AM
MassimilianoSantini
New Contributor

Hi all,

I'm developing an app with Appstudio Qt Creator

I'm trying to upload an image (camera photo) to my application server (java struts2) .

The server side, tested with an html form in desktop browser, works fine.
So I'm trying to do, in qml, the work that html form perform in browser environment.

Is NetworkRequest (ArcGIS.AppFramework) class suitable for this purpose?

Otherwise can I use directly some QML class or Javascript XMLHttpRequest ?

Thanks for your suggestions.

Massimiliano

0 Kudos
1 Solution

Accepted Solutions
LiweiGao
New Contributor II

Hi Massimiliano,

Please check the QuickReport->controls->FeatureServiceManager->function addAttachement(). This might be a good example for this question.

In this function, we defined an object "obj" and used it in NetworkRequest :

var obj = {"attachment": "@"+filePath, "f": "json"};
addAttachmentNetworkRequest.send(obj);

As can be seen, we contained file path for the image in this obj and sent it by calling send() function. I think the similar logic could be used to send images to a private server. 

Hope this helps,

LG

View solution in original post

5 Replies
nakulmanocha
Esri Regular Contributor

Yes, you can go ahead and use NetworkRequest to perform such operation. Make sure you have set the method to POST as the default values is GET. Infact we have used NetworkRequest in QuickReport to upload and add attachments such as images to featureservice which you can find in the QuickReport source code. For more help and reference please refer the NetworkRequest help page within Qt creator. There are few samples available to refer.

I hope this helps.

Nakul

MassimilianoSantini
New Contributor

Hi Nakul,

yes, I saw the QuickReport source code but what about if I try to send the image not to a FeatureserviceLayer?

I'm trying to send the file to my webapplication, no FeatureLayer used.

Something like this   addAttachmentNetworkRequest.send( image file??? );

Thanks again.

0 Kudos
LiweiGao
New Contributor II

Hi Massimiliano,

Please check the QuickReport->controls->FeatureServiceManager->function addAttachement(). This might be a good example for this question.

In this function, we defined an object "obj" and used it in NetworkRequest :

var obj = {"attachment": "@"+filePath, "f": "json"};
addAttachmentNetworkRequest.send(obj);

As can be seen, we contained file path for the image in this obj and sent it by calling send() function. I think the similar logic could be used to send images to a private server. 

Hope this helps,

LG

MassimilianoSantini
New Contributor

Hi,

you're right. I'm sorry,  I didn't use the "@"char!!! It's my fault.

Without this char I suppose that the attribute is evaluated as string.

Thanks a lot.

Massimiliano

0 Kudos
ManoKumar
New Contributor

Hi,

I am not able to upload file on private server, I checked the QuickReport source code but not able to get file on my php page on server, on php file I tried to print $_Request and $_FILE but not getting and image source, I am trying to resolve this issue last 2 days but no luck, Kindly help me

0 Kudos