Skip to content

Instantly share code, notes, and snippets.

@TheNotary
Created October 7, 2014 20:51
Show Gist options
  • Save TheNotary/a6d49660184690d38017 to your computer and use it in GitHub Desktop.
Save TheNotary/a6d49660184690d38017 to your computer and use it in GitHub Desktop.
ij
from arcpy import da
import os
inTable = arcpy.GetParameterAsText(0)
fileLocation = arcpy.GetParameterAsText(1)
with da.SearchCursor(inTable,['DATA','ATT_NAME']) as cursor:
for row in cursor:
binaryRep = row[0]
fileName = row[1]
# save to disk
open(fileLocation + os.sep + fileName, 'wb').write(binaryRep.tobytes())
del row
del binaryRep
del fileName
#ExportAttachments.py
#This script is for batch exporting attachments from ArcGIS Online.
#More info: http://www.cloudpointgeo.com/blog/blog/2014/3/5/getting-attachments-down-from-arcgis-online
from arcpy import da
import os
inTable = arcpy.GetParameterAsText(0)
fileLocation = arcpy.GetParameterAsText(1)
with with da.SearchCursor(inTable,['DATA','ATT_NAME','GlobalID']) as cursor:
for row in cursor:
binaryRep = row[0]
fileName = 'GlobalID_' + str(row[2]) + '-' + row[1]
# save to disk
open(fileLocation + os.sep + fileName, 'wb').write(binaryRep.tobytes())
del row
del binaryRep
del fileName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment