Writing Whole Files
When writing whole files, you configure a File Name Expression property in the destination. The expression defines the name for the output file.
Each whole file origin includes file information in the fileInfo fields. So you can easily base the output file names on the original file names from the source system.
The following table lists the field names that hold the input file name for each origin, and a basic expression that names the output file based on the input file name:
Origin | File Name Field Path | Base Expression |
---|---|---|
Directory | /fileInfo/filename | ${record:value('/fileInfo/filename')} |
SFTP/FTP | /fileInfo/filename | ${record:value('/fileInfo/filename')} |
Amazon S3 | /fileInfo/objectKey | ${record:value('/fileInfo/filename')} |
* Note that the objectKey field can include a field path as well as a file name. Use this expression when the objectKey is just a file name. |
Example
You want a pipeline to pass whole files from a local directory to Amazon S3. For the output file name, you want to append the .json file extension to the original file name.
The Directory origin stores the original file name in the /fileInfo/filename field,
so you can use the following expression for the Amazon S3 File Name
Expression property:
${str:concat(record:value('/fileInfo/filename'), ".json")}
Or, more
simply...
${record:value('/fileInfo/filename')}.json