Files
Introduction
The ArcGISAttachmentConnector provides users with the ability to easily manage attachments in ArcGIS Online & ArcGIS Enterprise Portal. This transformer provides the ability to add, delete, download, List, and upload attachments.
The ArcGISAttachmentConnector could be used for various purposes, such as:
- Synchronizing attachments between ArcGIS Online and ArcGIS Enterprise (or vice versa)
- Removing or updating outdated attachments
- Uploading externally collected data to existing ArcGIS records
- Integrating with external business systems (e.g., transferring files to/from ArcGIS as part of a business workflow)
- Exporting attachments for archiving before deleting features or performing data migrations
Requirements
- FME Workbench 2024.0+
- Esri ArcGIS Connector package version 3.9.5 or greater is installed
ArcGISAttachmentConnector Parameters
Authentication
- Connection: Users can specify an ArcGIS Online web connection or an ArcGIS Enterprise web connection.
Request
- Action: Users can choose to Add, Delete, Download, List, or Update attachments
Feature
-
Feature URL: Users must provide the Feature URL. In ArcGIS Online & ArcGIS Portal this can be found on the bottom right of the ‘layer overview’ page.
Best Practices
- Attachments can be uploaded/downloaded either as files or as attributes. When attachments are downloaded to an attribute, they are stored in the specified attribute.
- Working with attachments as attributes may be preferred because files do not need to be downloaded locally to your hard drive.
- If downloading to files, consider using the TempPathNameCreator to create a temporary folder. FME will clean this up automatically once the workspace finishes.
- When providing a Feature URL, you must include the layer index AND the ObjectID of the record you want to interact with.
- Optional: read in the layer first (using an ArcGIS Online Feature Service Reader or ArcGIS Portal Feature Service Reader) to obtain the ObjectID as an attribute and then use that in the Feature URL.
Step-by-step Instructions
Part 1: Downloading Attachments With the ArcGISAttachmentConnector
In this example, we will walk through how to download attachments from an ArcGIS Online Feature Service using the ArcGISAttachmentConnector.
1. Read the ArcGIS Online Feature Service
First, we’ll add an Esri ArcGIS Online (AGOL) Feature Service reader to a blank workspace to read in the layer we want to download attachments from. We need to retrieve the ObjectIDs for our records to use in the ArcGISAttachmentConnector Feature URL parameter.
For information on how to connect to Esri ArcGIS Online, see Tutorial: Getting Started with ArcGIS Online and Portal.
2. List Attachments
Next, we can add an ArcGISAttachmentConnector to our workspace and connect it to the ArcGIS Online Feature Service Reader.
We will use the List action in the ArcGISAttachmentConnector to get the attachment_id. Once we’ve retrieved the attachment_id we can then use this in a subsequent ArcGISAttachmentConnector to download the attachment.
In the ArcGISAttachmentConnector, we can set the parameters as follows:
- Connection: select your AGOL web connection or create a new one
- Action: List
- Feature URL: your feature URL including the layer index and ObjectID
When run, the ArcGISAttachmentConnector outputs a record for each attachment, including its attachment_id, attachment_name, and attachment_size.
3. Download Attachments
Next, another ArcGISAttachmentConnector can be added to the workspace and connected to the first one. In the ArcGISAttachmentConnector_2 parameters, we can set the parameters as follows:
- Connection: select your AGOL web connection or create a new one
- Action: Download
- Feature URL: your feature URL, including the layer index and ObjectID
- Attachment ID: _attachment_id
- Download as: File
- Download to Folder: C:\Temp\Attachments
- If File Exists: Overwrite
When run, the ArcGISAttachmentConnector downloads the files to the folder specified. The Output port also includes an attribute that contains the file path of the downloaded attachment (_downloaded_path).
Part 2: Uploading Attachments with the ArcGISAttachmentConnector
In this next section, we will explore how to use the ArcGISAttachmentConnector to migrate attachments from ArcGIS Online to ArcGIS Portal.
1. Modify the ArcGISAttachmentConnector
Continuing from the previous example, we will modify the ArcGISAttachmentConnector_2 to download the attachment as an attribute. The advantage of this is that we can provide this attribute when we want to upload the attachment to ArcGIS Portal, removing the need to download the attachments locally to a hard drive.
2. Read the ArcGIS Portal Feature Service
Because the ArcGISAttachmentConnector uses the ObjectID to determine which record to upload the attachment to, we need to read in our ArcGIS Portal dataset and join it to our attachments data using a unique identifier, in this case, the TreeID attribute.
3. Join the Attachments to ArcGIS Portal Records
After adding our ArcGIS Portal Reader to the workspace for our TreeInventory layer, we can a FeatureJoiner to join ObjectIDs to the attachments. In the FeatureJoiner, we are joining based on the TreeID, which we know is a unique identifier.
Note: set the Attribute Conflict Resolution parameter to Prefer Right if you have identical ObjectID column names between your two datasets. This will ensure that the output ObjectID value is from the dataset you want to write the attachments to.
4. Upload Attachments
Lastly, we can add another ArcGISAttachmentConnector to the workspace and connect it to our FeatureJoiner. The ArcGISAttachmentConnector parameters are set as follows:
- Connection: ArcGIS Portal Web Connection
- Action: Add
-
Feature URL: https://your-arcgis-portal.com/server/rest/services/Hosted/VancouverTrees/FeatureServer/0/@Value(objectid)
- This is the URL for the feature service in ArcGIS Portal. Again, this needs to include the layer index and the ObjectID
- Upload: Attribute
- Attribute to Add as File: _file_content
- Add with Filename: _filename
Once the ArcGISAttachmentConnector_3 has been configured, the workspace looks like this:
When the workspace is run, the attachments will be uploaded to the corresponding ArcGIS Portal records. You can verify this by opening the feature service in ArcGIS Portal and viewing the attachments under the Data view.