Files
Introduction
A key benefit of creating Data Virtualization APIs is their flexibility, with all aspects of their inputs and outputs customizable. FME supports file-based inputs and outputs, allowing users to upload and receive data in any format, matching the existing versatility of traditional workspaces.
With that being said, the process for file uploads is more complicated for file types without explicit MIME mapping
This tutorial walks through uploading an .fmw file, an example of a non-MIME mapping format. However, this logic can be applied to other non-MIME file types. Being a demo, this endpoint is fairly rigid, but it could be made significantly more flexible by using parameters or more complex file processing.
Requirements
- FME Form and FME Flow 2026.1 or newer.
- Familiarity with Data Virtualization: Please review Create a Data Virtualization API.
- You may also want to review Working with Files in Data Virtualization APIs.
Step-by-Step Instructions
This tutorial focuses on the file upload aspect of Data Virtualization, specifically for non-MIME-mapped file types. For detailed steps on creating a Data Virtualization API, see Create a Data Virtualization API.
1. Create a New Data Virtualization API
Log in to FME Flow 2026.1+. Navigate to Data Virtualization, click Create, and create a new API with the following settings:
API Details
- API Title: Working with Files without explicit MIME Mapping Tutorial
- Namespace: abc
- Summary: An API for processing uncommon file types.
- Description: Uploads an FME Workspace file (.fmw) to FME Flow
Endpoint Security
- Access Level: Unauthenticated
See Secure Data Virtualization Endpoints with Authentication for guidance on endpoint access levels.
Leave all other settings at their defaults. Then click Create at the bottom of the parameters list.
2. Create a New Endpoint
In the newly created API, navigate to the Endpoints tab and click Create. In the Details tab, enter the following settings:
Endpoint Details
- Path: /workspaceupload
- Operation: POST
Endpoint Security
- Inherit API Security: Enabled
Click Create in the top right.
3. Set the Parameters
While still in the /workspaceupload endpoint, in the Parameters tab:
- Query Parameters - Add
- NAME: workspacename
Then click Save.
4. Set the Request Body
Switch to the Request Body tab:
- Required: Yes
- Content Type: application/octet-stream
Then click Save.
5. Set the Response
Switch to the Response tab:
- Response Type: Workspace
Click Add Status Code:
First Status Code
- HTTP Status Code: 200 - OK
- Content Type: application/json
- Response Structure: Create Properties
Click Save. If a Workspace Update Required warning appears, click Save to ignore it.
6. Generate a New Workspace and Open it in FME Workbench
In the Workspaces tab, select the /workspaceupload endpoint, then from the Endpoint Actions drop-down, click Generate Workspace. This workspace will be for the single workspace upload. Also, this workspace is designed for testing in FME Flow, since it reads from and writes to the temporary engine results folders.
In the dialog, assign a name for the workspace.
Click Generate.
Open FME Workbench, on the start page, click Data Virtualization, select your newly created workspace, and click Download.
7. Expose the Source Path
Double-click the Reader, navigate to the Format Attributes tab, check source_path, and click OK.
8. Add a Logger
Add a Logger transformer, and connect it to the /workspaceupload Reader. Set its parameters as follows:
- Log Message: Feature is:
9. Add an AttributeManager
Add an AttributeManager and connect its Input port to the Logger’s port. In its parameters, set:
-
Add Attribute:
-
Output Attribute: filecopy_source_dataset
-
Value:
@Value(source_path)\@Value(request.body_file_path)
-
Value:
-
Output Attribute: filecopy_dest_filename
-
Value:
query.workspacename
-
Value:
-
Output Attribute: destinationFolder
-
Value:
$(FME_SHAREDRESOURCE_DATA)/uploadedWorkspaces
-
Value:
-
Output Attribute: filecopy_source_dataset
10. Add a FeatureWriter
Add a FeatureWriter transformer and connect its Output port to the AttributeManager. Set its parameters as follows:
- Format: File Copy
- Dataset: destinationFolder
-
Subfolder Name:
request.body_file_path - Output Ports: One per Feature Type
Click OK.
11. Add a Logger
Add a Logger, connect it to the FileProperties output port of the FeatureWriter, and input the following parameters:
-
Log Message:
workspace ID: @value(workspace_id)
Click OK.
12. Create a Success Message
Add an AttributeCreator and add the following values. Attach the Output port to the Writer.
-
Output Attribute: response.status_code
- Value: 200
- Type: uint8
-
Output Attribute: response.body.content
-
Value:
{"status":"successful"} - Type: vchar(23)
-
Value:
-
Output Attribute: response.body.content_type
- Value: application/json
- Type: vchar(16)
13. Publish to FME Flow and Test
Publish the workspace with all default settings to FME Flow.
14. Test the Endpoint with Swagger UI
To open Swagger UI, in FME Flow, click on API Details, then View Documentation. Expand the menu for POST /workspaceupload , and click Try It Out. For the workspace name, enter any name that ends in .fmw. This is important because FME will interpret application/octet-stream as binary and will reject it without the extension. When choosing a file, choose any FME workspace file, then click Execute.
You should see the successful response. Now in FME Flow, click Resources on the left. Then check Resources/Data/uploadedWorkspaces to confirm the workspace was uploaded. It should be in a folder similar to the one shown below.