The create-file function allows you to store stream content in a file that you may need to use in the future. Files created with the help of the create-file function are not temporary. Such files belong to the user and not to FlowForce.
The create-file function is similar to the as-file function in that it creates the specified target file with the specified stream content, but create-file does not create any temporary files. Use /system/create-file to store stream content that you intend to keep. Use as-file to pass the stream content as a file to some program. This might be a temporary file managed by FlowForce.
The source expression (see screenshot below) can be anything that returns a stream. You can use anything you can pass to the as-file function. For example, you could use the following options:
•stdout(result), stderr(result), result(result, name, index) get streams out of step results;
•mime-flatten(stream) produces a message/rfc822 stream from another by prefixing it with its MIME headers;
•mime-multipart(string, stream*) produces a MIME multi-part structure as a stream;
•stream-open(filename, contenttype) opens a file on disk;
•empty-stream() produces a zero-length stream;
•stream-from-string(text, encoding, content-type) encodes a string value into a stream.
The screenshot below illustrates the create-file function. Our goal is to create a file called CreateTest.txt and save it on the desktop. We are going to use the stream-from-string function, which encodes a string value into a stream. As a result, we will see our new CreateTest.txt file containing the string MyFileContent.
|Note:||To run the job, set a trigger and/or run the job as a service.|