I want to export the photos collected on my form in fieldmaps. I am able to see them when i open the map in ArcGIS, but I cannot find a way to download all at once.
@FatimaGamino ,The workflow below enables you to add a sensible prefix onto the name of the photo, defined by a field of your choice in your feature class, and downloads the lot into a folder of your choosing. Otherwise, you'll just end up with a load of photos with the same name.
Extract Attachments from a Hosted Feature Service to a folder with prefix name:
Script BELOW works in Pro
RELGLOBALID in table, to GLOBALID in FClass.
import arcpy from arcpy import da import os inTable = arcpy.GetParameterAsText(0) fileLocation = arcpy.GetParameterAsText(1) outputPrefix = arcpy.GetParameterAsText(2) with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID', outputPrefix]) as cursor: for item in cursor: attachment = item[0] filenum = "ATT" + str(item[2]) + "_" filename = str(item[3]) + "_" + filenum + str(item[1]) open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes()) del item del filenum del filename del attachment
I can get this to work to line 14, but no further...getting this error:
'str' object has no attribute 'tobytes'
This video may help https://mediaspace.esri.com/media/t/1_v3hg0nqg
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.