Add Attachment

930
4
07-24-2019 06:03 AM
AbdelrahmanAbdelrazek
New Contributor III

Hello everyone,

I'm using appstudio, and trying to add attachment to a feature service that doesn't enable reading capability.

I do so using 

featureServiceManager.addAttachment

But this doesn't work for me, could you please let me know if there is another way for adding attachments to it.
Thanks in advance.


0 Kudos
4 Replies
LucasDanzinger
Esri Frequent Contributor

I recommend you take a look at our sample code for modifying feature attachments - https://github.com/Esri/arcgis-runtime-samples-qt/blob/master/ArcGISRuntimeSDKQt_QMLSamples/EditData...

0 Kudos
AbdelrahmanAbdelrazek
New Contributor III

Thanks Lucas Danzinger‌ for your response.

I already had a look on it, but the problem that it works against a feature service that has read capability, which enables us selecting the feature and adding attachment, but in my case the feature service doesn't has read cabibility so no way to see the features and selecting them.

I think the only way for doing so, is through the sending post request to the rest endpoint but the header's content-type should be x-www-form-urlencoded, - i do this successfully using postman, but till now i'm not able to do so through QML.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Read only, meaning the Query endpoint is not enabled, correct? If correct, then I can't think of a good way to do this in the Runtime API, because you'd typically do this through a ServiceFeatureTable object. However, in order to populate the feature table with features, it will need to be able to call query on the service. 

Outside of the Runtime API, you could make a request like you mentioned. ex: http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0/3088311/addAttac...

With AppStudio you could use the NetworkRequest type perhaps - https://doc.arcgis.com/en/appstudio/api/reference/framework/qml-arcgis-appframework-networkrequest/

0 Kudos
AbdelrahmanAbdelrazek
New Contributor III

Yes, the query endpoint is not enabled, and as a result i can't make use of this way

 http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0/3088311/addAttac...

when i try to do so, it says "this operation is not supported" -- as shown in attached picture.

But i managed to find a way to do so, i'm only stuck in finding an equivalent to FileReader.readAsDataURL() which is used in javascript to provide file's data as a base64 encoded string.

https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL

If there is such a method in QML, i will be grateful if you let me know.

(a way for getting file's data as a base64 encoded string)

0 Kudos