Please maintain attachments when using the append method on a hosted feature layer.
When following these instructions:
https://www.esri.com/arcgis-blog/products/arcgis-online/data-management/keeping-layers-updated-by-appending-features-using-the-arcgis-api-for-python/
Append does not maintain attachments that are located in the hosted file geodatabase.
def add_attachments(survey_monuments_fl, attach_table): df = pd.read_csv(attach_table) for s in zip(df['Path'], df['GlobalID']): if not type(s[0]) == float: # make sure path is not empty attach_path = os.path.join(project_folder_path, s[0]) globalid = s[1] feature = survey_monuments_fl.query(where=f"GLOBAL_TEXT = '{globalid}'") objectid = feature.value['features'][0]['attributes']['OBJECTID'] objectid = int(objectid) update(f"Adding attachment {attach_path} to {objectid}") survey_monuments_fl.attachments.add(objectid, attach_path)
and GlobalID
I also needed to save GlobalID as a text field in the Feature Layer I am pretty sure because Esri likes to change those.
This is how I made the fl object
itemid = #itemidhere survey_monuments_item = gis.content.get(f"{itemid}") survey_monuments_fl = survey_monuments_item.layers[0]
Second this idea! Unable to find way to maintain attachments. Looking to script adding attachments after append-but why the workaround for this?
This is specifically for the ArcGIS API for Python. You cannot set that in an environment variable for the API... Unless you know something I don't know.
See Reference:
https://developers.arcgis.com/python/api-reference/arcgis.features.html#arcgis.features.FeatureLayer.append
@ZacharyNeumannQK not sure if this is an idea, because you can select "Maintain Attachments" in the environment variables for Append
Melden Sie sich an, um zu posten, Inhalte zu folgen und mehr. Neu hier? Kostenlos registrieren.