Training Day

File-Based Transport

Using files as a transport mechanism for data integration with FileMaker

File-based transport mechanisms remain one of the most common and reliable methods for exchanging data between FileMaker and other systems.

File-Based Integration Overview

File-based integration involves systems writing data to files that other systems read. This approach:

  • Requires minimal setup
  • Works across virtually all platforms
  • Doesn't require systems to be simultaneously online
  • Provides built-in audit trails (the files themselves)

Common File Transport Protocols

FTP (File Transfer Protocol)

The traditional protocol for transferring files between systems:

  • Simplicity: Easy to implement and understand
  • Widespread support: Available on virtually all platforms
  • FileMaker access: Available through Insert From URL with cURL options
  • Limitations: Lacks encryption in its basic form
Insert From URL [Select; $result; "ftp://username:password@ftp.example.com/path/file.csv"]

SFTP (SSH File Transfer Protocol)

Secure version of FTP that encrypts both authentication and data:

  • Security: Provides encryption and stronger authentication
  • Modern standard: Preferred over FTP for security reasons
  • FileMaker access: Available through Insert From URL with cURL options
Insert From URL [Select; $result; "sftp://username:password@sftp.example.com/path/file.csv";
  cURL options: "--key /path/to/private_key"]

Shared Network Drives

Direct access to files on network-accessible storage:

  • Simplicity: Works like local file access
  • Low latency: Fast for same-network systems
  • FileMaker access: Native through Import/Export Records
  • Limitations: Usually restricted to internal networks

File Formats for Data Exchange

Common formats used in file-based transports:

  • CSV: Simple tabular data
  • XML: Structured data with schema support
  • JSON: Modern, hierarchical data format
  • Excel/XLSX: Office-compatible spreadsheets
  • PDF: For document exchange

FileMaker Capabilities

FileMaker provides robust support for file-based transport:

Import Records

The Import Records script step can import from various file formats:

Import Records [No dialog; "/path/to/file.csv"; Create; UTF-8]

Export Records

Export Records can create files in multiple formats:

Export Records [No dialog; "/path/to/export.xml"; XML]

External File References

FileMaker can reference external data sources:

  • Excel and CSV files
  • XML files
  • Other FileMaker files
  • ODBC data sources

Send Mail

FileMaker can email files as attachments:

Send Mail [Send via SMTP Server; With dialog: Off; To: "recipient@example.com"; Subject: "Data Export"; Message: "Attached is the exported data."; Attach: "/path/to/export.csv"]

Implementing File Drops

A common pattern for file-based integration is "file drops" where:

  1. System A writes files to a designated folder
  2. System B monitors that folder for new files
  3. System B processes files when they appear
  4. Files are moved to an archive folder after processing

FileMaker Implementation

# Script to monitor a folder for new files
Set Variable [$folder; Value: "/path/to/dropbox/"]
Set Variable [$files; Value: Get ( DirectoryContents ; $folder )]
If [not IsEmpty($files)]
   # Process each file
   For each [$file; $files]
      If [RightWords($file; 1) = "csv"]
         Import Records [No dialog; $folder & $file; Create; UTF-8]
         # Move file to archive
         Set Variable [$result; Value: MBS("File.MoveFile"; $folder & $file; $folder & "archive/" & $file)]
      End If
   End Loop
End If

Best Practices

  1. Use standardized naming conventions: Include timestamps, source system identifiers
  2. Implement error handling: Deal with malformed files gracefully
  3. Set up monitoring: Track file arrivals, processing status
  4. Consider scheduling: Coordinate timing between systems
  5. Maintain archives: Keep processed files for audit purposes
  6. Secure file locations: Restrict access to file drop locations