FileTransformPipeline interface

A JavaScript object implementing the FileTransformPipeline interface, used to set up a file transform pipeline.

Construction

Use O.fileTransformPipeline(), passing in optional name and data arguments if you’re using a callback.

Interface (setup functions)

These functions set up the files and transforms to be applied.

function file(name, storedFile)

Add a file from the file store as an input to the pipeline, with the given name.

storedFile must be a File object.

function transform(name, specification)

Add a transform step to the pipeline. name specifies which transform is required, and specification is a JSON compatible data structure specifying the details of what is to be transformed.

See the file transform pipeline overview for a list of available transforms.

function rename(fromName, toName)

Add a transform step which sets the file in the pipeline named toName to the file currently named fromName.

This is useful for chaining transforms steps without having to explicitly specify the input and output files each time.

function transformPreviousOutput(name, specification)

A shortcut function to use the output of the previous step as the input to this step, when transforms have single input and output files and use the default names. It’s equivalent to:

    pipeline.rename('output','input');
    pipeline.transform(name, specification);

Interface (download of results)

These functions generate URLs and views which allow the results of the pipeline to be downloaded by the user without adding them to the file store. Each of them has a name and filename arguments.

name is the name of the file in the pipeline’s file list, usually "output".

filename is the user visible name of the file. Remember to include an extension.

function urlForOutputWaitThenDownload(name, filename, view)

Generate a URL to a user interface, implemented by the platform, which shows a progress bar while the file is being generated, then downloads the file. Use this to implement the recommended “redirect after POST” pattern after form submission.

view contains extra information for rendering the UI, with keys pageTitle, backLink, backLinkText and layout with definitions as in render(). Note that not all layouts are supported.

When this is used within a covering opened with Haplo.ui.openCovering(), set closeCoveringButton to true in the view to display a button to close the covering after the download is complete.

If the filename has no extension, or the wrong extension, an appropriate file extension will be added.

function viewToWaitForOutput(name, filename)

Returns a view for use with the std:wait_for_download template to show a progress bar then download the file.

If the filename has no extension, or the wrong extension, an appropriate file extension will be added.

function urlForOutput(name, filename)

Returns a URL, which can be fetched immediately. It will wait without sending any data until the pipeline is complete, then respond with the generated file.

Only use this for building APIs to work with other software. Use urlForOutputWaitThenDownload() when building UI to ensure a good user experience.

If the filename has no extension, or the wrong extension, an appropriate file extension will be added.

Interface (waiting UI)

function urlForWaitThenRedirect(redirectTo, view)

Generate a URL to a user interface, implemented by the platform, which shows a progress bar while the file is being generated, then redirects to the path in redirectTo.

view contains extra information for rendering the UI, with keys pageTitle, backLink, backLinkText and layout with definitions as in render(). Note that not all layouts are supported.

Use this when you are going to use the result of the output in the callback, but want the user to wait while it’s being generated.

Interface (execute pipeline)

function execute()

Execute the pipeline in the background. When the pipeline is complete, the files will be downloaded by the user and/or the callback called, depending on how you are using the pipeline.

After you call execute(), you cannot call any of the other functions.