The issue I'm having is with the AttachmentManager module. I wrote a quick code to download all of the attachments for a feature layer stored on ArcGIS online.
############# Get logged in and set up ###############
from arcgis.gis import GIS
PortalUrl = "https://www.arcgis.com"
username = ""
password = ""
FeatureLayerID = "e5c2bdc5755e4e21ab578550f2fa12a3"
SavePath= r"C:\Users\cschooley\Documents\Work\Heritage\Photos"
################# End Set-up #######################
if username == "" and password == "":
gis = GIS()
else:
gis = GIS(PortalUrl, username, password)
FeatureLayer = gis.content.get(FeatureLayerID)
layer = FeatureLayer.layers[0]
layer.attachments.download(oid = 1, save_path=SavePath)
It works just fine, but the issue I am having is that when it saves into the path I created, it creates a new folder for the ObjectID of that feature and the AttachmentID of that feature, nesting my photos behind two of their own folders.
['C:\\Users\\cschooley\\Documents\\Work\\Heritage\\Photos\\1\\18\\2015-04-11 10.35.42.jpg']
I am wondering if there is a way to work around this. I would like to have the photos save directly into the 'photos' folder without the creation of the other folders.
I suppose using the os module could work, but that's a little over my head. I found this article which has been kind of helpful, but I couldn't get his code to work for me, which is why I wrote this one above. It was simpler and didn't have the extra stuff I didn't need. I only need to download the photos, not necessarily have all the information (ObjectIDs, etc.) attached to them.
Thank you.
P.S. The feature ID used in the code is a public one, not the one I'm actually trying to use since that one is protected within my organization. It's from the JoshuaTreeHike feature server. It's the same set-up as mine though, where the Attachment IDs don't necessarily match the ObjectIDs.