I'm updating this answer based on the current version. You can export to a file geodatabase that will contain the attachments.
Navigate to the item page of your hosted feature layer.
Find the layer you want to export features and click the small arrow next to the name to reveal a context menu, and export the data to a file geodatabase. You can then download a ZIP file of the geodatabase, that will contain the attachments
---------------
Original Reply
Export of attachments is supported through the API only at this time. It was not included in the update this week.
You can navigate to the REST endpoint of your service, like this:
http://services.arcgis.com/xyz/arcgis/rest/services/states/FeatureServer
Click Create ReplicaSpecify the Layers by index number e.g., 0,1,2 (this service above has 5 layers)Set the boolean values to true.Sync Model = noneData Format = FileGDBClick Create Replica.
This will start a process that will yield a zip file you can download.
Thanks,
Mike
I believe that your attachments are not working because the GLOBALID of the new dataset you created no longer reference the RELGLOBALID that is used to related those attachments back to their original features. Or in the case of not using a GLOBALID, the OBJECTID has changed from previous datasets that you merged together, which can also be used as the reference ID for attachments, it all depends on how you setup the original attachments.
Hi, I have a question about attachment tables. I have datasets more than one and an attachment table for all these datasets. I want to unite my dataset layers on one layer and reestablish the relation between attachments. I created a new relationship class, it works but couldn't get the attachments. Does anyone have any opinion about this?
Thanks
I exported a FGDB as described above, but no attachments/photos were included. Is there something I'm missing?
Thank you Randy! I'll try the python script.
Thank you Mike!
I believe this may be of assistance to you: Python script to pull hosted features with attachments into a local file geodatabase. See ReadMe below.
S Garg
First, I don't write much code, so this is my best guess...
The ability to export is part of the REST API. I believe that you can make REST calls through Python. Thus, it seems possible to automate this process. Keep in mind that the API will create an item in ArcGIS Online that is a ZIP file of the file geodatabase.
I believe this is the correct API reference.
ArcGIS REST API
Hi Mike - just saw your updated answer about exporting the layer and attachments into a zipfile. Is there a way to use python to achieve the same in an automated manner instead of manually having to go through the steps on AGO? This will be especially useful for downloading copies of multiple such layers (with attachments) on a regular basis.
Thanks!S
Hi Mike,
Not sure what you mean -- what are signup coupons?
Brian,
This looks like a good a solution. Can you please send more info on getting "signup coupons"?
Export your feature service data as a file geodatabase. This creates a new item which you can then download (zip file).
the attachments are automatically included.
You can do this programmatically using Arcrest site package from Github. I think there is even an example here: Another GIS Blog: Using ArcREST to Export Hosted Feature Services
Trill
Thank you for the response.
I have done as suggested above . Still got the error as below. I must be doing something wrong.
I also tried some of the above mentioned proxy setting. I have tried the SETX and I have tried the def get_response as mentioned in your post above.
That's it (I'm a complete newbie to working with the REST API)! Thanks for the quick reply!
I started to piece it together late yesterday when I came across these suggested edits for working with proxies in another feature service script on github.
I ended up using pacparser on my office's wpad to determine my server ip and port and hardcoded them
os.environ['http_proxy'] = "http://" + pxy_user + ":" + pxy_pass + "@ + pxy_srvr + :" + pxy_port
thanks again!
Hi Stephen,
You need to enter your credentials in the last if clause at the bottom of the script:
if __name__ == "__main__":
TOKEN = login("yourUserNameHere", "yourPasswordHere")
Let me know if it works...
-Trill
When you're running SETX you're entering your specific user information as well as server and port info, right? Sorry if that's a silly question, but just wanted to make sure. In lieux of using SETX in the command line to reset the environment variables, you could also include urllib2 proxy handlers directly in the get_response def as shown below -- this is probably a more elegant solution:
def get_response(url, query='', get_json=True):
opener = urllib2.build_opener(
urllib2.HTTPHandler(),
urllib2.HTTPSHandler(),
urllib2.ProxyHandler(
{'https': 'http://yourUserName:yourPassword@YourProxyIP:ProxyPort',
'http': 'http://yourUserName:yourPassword@YourProxyIP:ProxyPort',
))
urllib2.install_opener(opener)
encoded = urllib.urlencode(query)
request = urllib2.Request(url, encoded)
if get_json:
return json.loads(urllib2.urlopen(request).read())
return urllib2.urlopen(request).read()
If you don't want to hardcode your info into the proxy handler, you could use this instead, which would allow you to enter your credentials via the command line:
{'https': 'http://' + sys.argv[1] + ':' + sys.argv[2] + '@YourProxyIP:ProxyPort',
'http': 'http://' + sys.argv[1] + ':' + sys.argv[2] + '@YourProxyIP:ProxyPort'}
If you do it this way, don't forget to import the sys module at the top of your script: import sys
You'd then enter the name of the script and your credentials in the python prompt like this:
>>> nameOfScript yourUserName yourPassword
Keep in mind that if you have special characters in your credentials (@, &, etc.) yourUserName and yourPassword need to be surrounded by double quotes.
Hope this works for you, please let me know if you need any more pointers.
- Trill
Trillium,
I am trying to use your BackupServiceAttachments.py. I am not a python expert, so I am doing what I can to try to get this working. I need to get this script working for my project, it does exactly what I need done.
I have changed the relevant sections like.
serviceTodayString =
serviceYesterdayString =
When I run the script it creates the folder and then stops with the following error.
{u'message': u'Unable to generate token.', u'code': 400, u'details': [u'Invalid username or password.']}
I am not sure where I should be adding my username and password ? There is a few places in the code where username and password gets mentioned.
Can you please give some direction even if you just give me the line where the username and password should be entered.
Kind regards
I'm trying to use Trill's script.
It works when I monitor the http traffic with Fiddler, but fails with urllib2.URLError: urlopen error 10061 'no connection could be made because the target machine actively refused it' when I run the script without Fiddler open.
I believe Fiddler makes it work because it is essentially acting as a proxy while it is open. Simply running SETX https_proxy http://user:pw@serverIP:port in the command prompt doesn't seem to cut it for me.
Any suggestions?
thanks,
*My office uses a wpad.dat for the proxy if that matters
For anyone who is still looking for answers on extracting attachments from a secured ArcGIS online-hosted feature service: I've been working with Brian Brown (who has been helpful byond the call of duty) on developing a script that I can use to download attachments and replicate the entire hosted feature service locally.
Brian's base code can be found on his github site: https://github.com/bgeomapping/arcgis-toolboxes
I made some minor modifications to it, which are included in the attached code:
Other things to note: if the specified url ends in FeatureServer, the entire service will be replicated and all attachments for all layers with attachments in the service will be downloaded. If the specified url ends in FeatureServer/<layer index>, only that layer will be replicated and only attachments for that layer will be downloaded. Also, the code creates the following subdirectories for attachments: Layer > Feature OID > attachments, as well as an 'All attachments' folder -- I don't need the 'All attachments' portion, so it's commented out. This should work in both Python 2.6 and 2.7 (I've tested in 2.6, Brian in 2.7) and is written so that ArcGIS need not be installed on the machine running the script (in other words, no arcpy import).
I hope this helps some of you!!!
Getting an error now when trying to edit the layer definition. Nothing was edited but the "maxRecordCount" and a constant error of" Invalid definition for 'LastEditDate'. Even when I am NOT editing the "maxRecordCount" and press the "Update Layer Definition" button this error occurs on each of my feature services. I am hosting all the data on ArcGIS Online and not running a server.
For performance reasons, we don't recommend setting the value above 2000.
How to update the Max Record Count of a Feature Service in REST
If your goal is to just extract the data with attachments from an ArcGIS Online hosted feature layer, our recent update now supports exporting a file geodatabase of the layer with all attachments. This shouldn't require increasing the query limit on the service endpoint.
Use hosted features and tiles—Help | ArcGIS
I found out that you can change the amount of records that the feature service displays and downloads when you make a local copy
The steps taken in order to access the Service Definition File were the following:
I have just collected 1500 points each with attachments(pictures) and it seems that when create a local copy for editing to use the script to extract the attachments I can only get 1000 features to copy over, is this a arcgis online file limit? a setting's feature limit? How can I get all my features downloaded, and have each features attachments saved locally. I have been successful before I went out and collected all 1500 with a few hundred and everything worked fine, now it seems that since I have over 1000 features and it's hosted on arcgis online there I can not create a local copy with every feature!Please some help would be helpful.-Rich
There is a script will extract attachments to files: http://support.esri.com/em/knowledgebase/techarticles/detail/41763
Is there a way to export the attachments out of the database and into a file folder. For instance, I would like to be able to take all of the attachments and produce .jpg images in a folder external to the database. Currently, I would have to open each attachement individually and perform a Save As. This won't fly when I have to do that 1000 times. Having the ability to export all attachements would be ideal. Having the ability to export these attachements and assign a file name based on table attributes would be even better.
Hi,Is it possible that, with ArcGIS Desktop 10.2 edition , can be save all attachments(photos) from ArcGIS online feature service?
ArcGIS for Desktop 10.2 will support "Creating a local copy" of the service that will also contain the attachments.Thanks,Mike
We hope to support this in a future update.
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.