Select to view content in your preferred language

Fetching Attachments from hosted FeatureServices REST endpoint

7457
3
Jump to solution
03-07-2013 10:58 PM
AnttiKajanus1
Deactivated User
Hi,

This post has 2 things, first one interesting scenario how the REST endpoint is working and second part some questions how to work with the Attachments.

I have hosted FeatureService with attachments enabled in the ArcGIS Online and I use direct REST query to add/update them from my Windows Service. I have noticed that the feature part of REST doesn't affect the attachment query at all and I can access all attachments from any feature endpoint.

The case here is that we have published Feature Service that contains some traffic cameras around Finland and we are adding / updating the images to the Features as a attachments. At background I have Windows Service that does some SOAP calls to another system were we get the updated images in not-so-easily-used-in-the-ArcGIS-systems.

--- Test case ---

FeatureService :
http://services.arcgis.com/4PuGhqdWG1FwH2Yk/arcgis/rest/services/Mittauspisteet/FeatureServer/0

Access to Feature:
http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/44

List of Attachments with Feature 44:
http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/44/a...

Feature 44 has only 1 attachment with ID = 32.

CASE 1:
Access to Attachment with ID = 32

http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/44/attachments/32

--> I get correct Attachment

CASE 2:
Access to Attachment with ID = 33

http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/44/attachments/33

--> I get Attachment that is assigned to Feature 45

CASE 3:
Access to Attachment with ID 32 but in context of Feature 45

http://services.arcgis.com/4PuGhqdWG1FwH2Yk/ArcGIS/rest/services/Mittauspisteet/FeatureServer/0/45/attachments/32

--> I get same attachment that I get in case 1

-----------------------------------------

CONCLUSION:

The Feature specified in the URL actually doesn't do anything and I can access to all Attachments in context of any existing feature.

-----------------------------------------

QUESTIONS:

I haven't tested this with service that is hosted in the ArcGIS Server but do you know if it works the same and is this the behavior how it should be working? At least from my perspective, if we are using the Feature in the structure, then the query should only affect attachments that are associated with that.

Can attachments be accessed with some other Identifier than it's Id? Like with the uploaded name directly from the REST. In my case, I wouldn't like to make AttachmentInfo call for every Feature. As a round work, we have the Attachment id stored in the feature by itself so we can construct the Image Url directly from the information known. In our case, each Feature should have only 1 attachment that is updated in the background. There are Features that doesn't have any attachments yet so we cannot directly relay that Feature ObjectId == Attachment Id even if we add Attachment in order. Any thoughts on this?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KhaledHassen
Esri Contributor
Hi,

For the answer to the first question
--> I get Attachment that is assigned to Feature 45
This is incorrect. You should receive attachments for the featureId you are passing in the REST call.
We will fix that in the next release.

>Can attachments be accessed with some other Identifier than it's Id? Like with the uploaded name directly from the REST. In my cas>e, I wouldn't like to make AttachmentInfo call for every Feature. As a round work, we have the Attachment id stored in the feature

We do support Upload API on the hosted feature service.
http://services.arcgis.com/4PuGhqdWG...eatureServer/Uploads. You can upload up to 10M of any attachments. Once you upload the item, you will get an identifier you can use to get the item bytes back.
But this is for temp storage only and not meant for permanent storage. The uploaded item will have a limited life time.

Thanks

Khaled

View solution in original post

0 Kudos
3 Replies
KhaledHassen
Esri Contributor
Hi,

For the answer to the first question
--> I get Attachment that is assigned to Feature 45
This is incorrect. You should receive attachments for the featureId you are passing in the REST call.
We will fix that in the next release.

>Can attachments be accessed with some other Identifier than it's Id? Like with the uploaded name directly from the REST. In my cas>e, I wouldn't like to make AttachmentInfo call for every Feature. As a round work, we have the Attachment id stored in the feature

We do support Upload API on the hosted feature service.
http://services.arcgis.com/4PuGhqdWG...eatureServer/Uploads. You can upload up to 10M of any attachments. Once you upload the item, you will get an identifier you can use to get the item bytes back.
But this is for temp storage only and not meant for permanent storage. The uploaded item will have a limited life time.

Thanks

Khaled
0 Kudos
AnttiKajanus1
Deactivated User
Thanks for the reply Khaled.

So it was a bug. Good to know because that would have broken the link we are using in WebMaps if we don't include the ObjectId to it's correct place.

I quess that the Attachment Id's are still FeatureService and not feature wide. So I need to get the attachment id fetched anyway?

Thanks for pointing Upload API out, haven't checked that earlier. In our case, we want to have our information (feature information and the picture) used easily in the ArcGIS platform products. If you compare the usage between Upload and Feature Attachments, do you think that Upload can be considered as easily consumed manner? If I understood the concept of Upload correctly, I still want to use Feature Attachments as a storage for images so those can be easily accessed from WebMaps and other clients. For example, it is easy to attach the image for WebMap's popup with Image tag.

with regards,
Antti
0 Kudos
KhaledHassen
Esri Contributor
>I quess that the Attachment Id's are still FeatureService and not feature wide. So I need to get the attachment id fetched anyway?

Actually the attachment Ids are layer based. So you might see the same attachment Id for two layers that have attachments.
You can query a feature and get the list of attachments info which would include the attachmentId. You can use that attachment Id later to get the attachment image/bytes.

>do you think that Upload can be considered as easily consumed manner? If I understood the concept of Upload correctly, I still want>to use Feature Attachments as a storage for images so those can be easily accessed from WebMaps and other clients. For example,> it is easy to attach the image for WebMap's popup with Image tag.

It is a straight forward to use the feature service upload API. It is supposed to simplify the attachment upload experience in some workflows. For instance, when you need to sync a local copy of the data with online content, you can use the upload API to upload many files/images, and then sync the local content by using only the upload Ids you are getting when uploading your attachments. Please let us know if you have any issues or enhancement in consuming the API.

Thanks

Khaled
0 Kudos