Select to view content in your preferred language

Get Attachments from a Feature Service with Attachments enabled over SSL

4843
4
07-20-2012 05:20 AM
GrahamWhelan
Emerging Contributor
Hello

I'm stuck on an issue at the moment trying to get attachments from a secured Feature Service.

Basically what I am trying to do is display attachments associated with a record in the popup in an image gallery. I've been able to build a URL based on results of the query and I am using a XMLHttpRequest to get the JSON of the Attachments page for the record.

Example URL:
http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/MapServer/0/438...

This returns the JSON object containing the attachment info and then if there are images the URL can be modified to append the file names to use them as the src of the images in the image gallery.

This works fine on non secured services but when I tried to access our live service which is secured with SSL my request is returning an access denied error.

Im not sure what is the best practice to get at the attachments but there doesn't seem to be anything in the API for it, unless I'm missing something.

Has anyone else tired to do this and is there a solution? Or is there a better way of doing it that I am missing?

Thanks in advance,
Graham Whelan
0 Kudos
4 Replies
derekswingley1
Deactivated User
You can view attachments via the attachment editor:  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/ed_attachments.html

Use the Identity Manager to handle access to secure services:  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/widget_identitymanager.html
0 Kudos
GrahamWhelan
Emerging Contributor
Hi Derek

Thanks for the response. I have seen both of those examples, however the attachment editor loads up all the attachments in a list of links using the dijit. It seems pretty difficult to then access the URL's / attachments at runtime.

I've been trying to pull the attachment list from the widget after a query but the dijit doesnt provide any oncomplete or onupdate events.

How would you reccommend using the dijit to get the attachments at runtime. As I said before I need to get the images for an image gallery.

Thanks,
Graham
0 Kudos
BrendanDwyer
Frequent Contributor
Graham,
I'm looking to do something similar.  I want to display the attachments in a gallery in a dijit.  Have you worked this out?

Thanks,

Brendan
0 Kudos
GarthTissington
Emerging Contributor
have you looked at the

queryAttachmentInfos(objectId, callback, errback) method on the feature layer object?

http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/featurelayer.html#queryAttachmentInfos