How do I download all ArcGIS Online attachments from a hosted feature layer made from a Survey123 form?

16520
21
07-20-2020 01:13 PM
KaitlynAbrahamson
Occasional Contributor

Hello,

I have seen some work on this question on GeoNet before, but I absolutely can't get my attachments from a hosted feature layer downloaded.  I have a Survey123 feature layer with a photo repeat that I have tried exporting to a file geodatabase without success.  All I get is the standard 1KB file that will not unzip.  I tried creating a replica without success as well; I keep getting error messages.  I also tried using a notebook with script I've found on this site, but I am so new to Python, that I have not been able to get it to work.  Please help!

21 Replies
Katie_Clark
MVP Regular Contributor

To confirm, you followed this workflow to try to download the fgdb? This is the only one that's always worked for me...

How To: Download attachments from a hosted feature service 

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek
KaitlynAbrahamson
Occasional Contributor

This is what I followed, but I can never get a final link for download.  I always run into errors like the one below.

"Error in creating runtime geodatabase."

0 Kudos
KaitlynAbrahamson
Occasional Contributor

I was able to create a replica, but I'm not sure where the photos are actually saved, let alone the sketches from our Survey123 crew in the field are.  How do I access the actual photos and know which points they belong to?

0 Kudos
Katie_Clark
MVP Regular Contributor

So do you have the data within a file geodatabase? If so, there should be an attachments table that will contain the photo data. 

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek
0 Kudos
KaitlynAbrahamson
Occasional Contributor

These is an attachments table, but I want to see the actual photos and the exif data.  How do I see those?

KaitlynAbrahamson
Occasional Contributor

Is there a way to actually save jpg files that I can open and see the photo?  That's really what I need.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Kaitlyn Abrahamson‌ you can use the following code to export the images:

import os, arcpy

# Variables
tbl = r"C:\Temp\Python\Test.gdb\Graffiti__ATTACH"       # Path to attachment table
fldBLOB = 'DATA'                                        # Field name of Blob data type field in attachment table
fldAttName = 'ATT_NAME'                                 # Field name in attachment table that contains attachment name
outFolder = r"C:\Temp\Python\Attachments"               # Output folder to export attachments to

with arcpy.da.SearchCursor(tbl,[fldBLOB,fldAttName]) as cursor:
   for row in cursor:
      binaryRep = row[0]
      fileName = row[1]
      # save to disk
      open(outFolder + os.sep + fileName, 'wb').write(binaryRep.tobytes())

print('Finished')
KaitlynAbrahamson
Occasional Contributor

Yes!  I finally got it to work!  Thank you so much for your help.  It was invaluable.

0 Kudos
ScottDeNeicev1
New Contributor

Is there a way to connect to the hosted feature service without having to download the filegdb first?