Writing to a File
You can use the Filesystem adapter to write data to a file in the filesystem.
Writing a File
Using the write operation of the Filesystem adapter, you can write a file to the filesystem.
Name | Type | Direction | Description |
---|---|---|---|
data | Blob | in | Content you want to write to the file. |
name | String | in | Fully qualified file name of the file you want to write, including the path. When using the Windows style with backward slashes "\" you have to be aware that you need to escape this character. The escape character is also the "\". |
position | Integer | in | Position (in Bytes) from which you want to start writing the file. |
length | Integer | in | Length (in Bytes) of the data you want to write, if you want to only write part of the Blob. |
Replacing the File
Specifying only data and length (optionally), you can write a complete file. If the file is already existing, it will be overwritten with the new content.
Writing Data to a Specified Position in the File
Alternatively, you can use the write operation with the position to write data to a specific position. position defines the byte position within a file to which the new content should be written. Depending on the length of the new data, this will result in a partly update of the file content, and/or an extension of the file.
Related Error Codes
Find a list of all File System Adapter error codes on System Errors of the File System Adapter.
Error Code | Description |
---|---|
| Failed creating file. |
Appending Data to a File
Using the append operation of the Filesystem adapter, you can append data to a file in the filesystem.
Name | Type | Direction | Description |
---|---|---|---|
data | Blob | in | Content you want to write to the file. |
name | String | in | Fully qualified file name of the file you want to write, including the path. When using the Windows style with backward slashes "\" you have to be aware that you need to escape this character. The escape character is also the "\". |
length | Integer | in | Length (in Bytes) of the data you want to append, if you want to only write part of the Blob. |
Modes
You can use the append operation with two modes:
append
If the mode is empty or append, the content stored in data will be appended to the end of the file specified in name. If the file does not exist, it will be created.overwrite
If mode is overwrite, the file specified in name will be overwritten with the content stored in data. If the file does not exist, it will be created.
overwrite will only be applied to the first append. For all subsequent appends (e.g. in a loop), the mode will be switched to append automatically.
Closing a File
On end of the service request, all files that have been used with the Filesystem adapter are closed automatically. In some cases, it may be helpful to manually close a file (e.g. if you want to rename or push the file).
You can close a file using the close operation of the Filesystem adapter.
Name | Type | Direction | Description |
---|---|---|---|
name | String | in | Fully qualified file name of the file you want to close, including the path. When using the Windows style with backward slashes "\" you have to be aware that you need to escape this character. The escape character is also the "\". |
The path and file name of the file you want to close can be given dynamically via input parameter name, or statically via the definitions of an alias.
FilesystemAdapter_ProductExport_Example
Click here to download a simple example model that shows the usage of the Filesystem adapter in Scheer PAS Designer.