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!
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
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."
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?
So do you have the data within a file geodatabase? If so, there should be an attachments table that will contain the photo data.
These is an attachments table, but I want to see the actual photos and the exif data. How do I see those?
Is there a way to actually save jpg files that I can open and see the photo? That's really what I need.
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')
Yes! I finally got it to work! Thank you so much for your help. It was invaluable.
Is there a way to connect to the hosted feature service without having to download the filegdb first?