Binary Router

Overview

This Snap routes binary documents to different output views based on a boolean expression.



A binary document consists of the binary content and a header that contains metadata for that content. For example, a file containing JSON data might have a header with a 'content-type' field set to 'application/json'. This Snap then allows you to separate a single stream of binary documents into multiple streams based on their header data. For example, when unzipping an archive with the ZipFile Read Snap, any files with a "content-type" of "application/json" could be sent to a JSON Parser and "text/xml" files could be sent to an XML Parser. The set of header fields available depends on the Snap that outputs the binary document. You can click on the preview icon for a binary view to see the content and headers that are being generated for each binary document. The following fields are often available:
Name Example Description
content-type application/json The MIME type for the binary content. If not available from the original source, this value will be derived from the file name.
content-length 1234 The length of the binary content.
content-location sldb://test.json The URL for the original source of the binary stream.
last-modified 2014-07-17T17:12:03.000 UTC The date that the binary was last modified.
Note:

Header fields are not yet available in the schema drop-down for the properties; consult the preview data to see what fields are available.

Snap views

View Description Examples of upstream and downstream Snaps
Input This Snap has exactly one binary input view.
Output This Snap has at least two binary output view.
Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when an error occurs.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap settings

Legend:
  • Expression icon (): Allows using pipeline parameters to set field values dynamically (if enabled). SnapLogic Expressions are not supported. If disabled, you can provide a static value.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: Binary Router

Example: Binary Router
Routes String/Expression Required. Expression to evaluate and output views to write a binary document if the expression evaluates to true. The Expression should be applied to the fields available in binary document header. List of expressions can be seen in Understanding Expressions in SnapLogic.
First match Checkbox If true (selected), then the first output view whose corresponding expression evaluates to true will only have the binary document written to it even if there are other matches. If false (not selected), then all output views whose corresponding expression evaluates to true will have the binary document written to it.

Default status: Deselected

Example: Expression | Output View Name

$["content-length"] > 1000 | output1

$["content-length"] <=1000 | output2

Snap execution Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Execute only

Example: Validate & Execute

Example:

Pipeline Demonstrating the Binary Router Snap