Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Snap type:

Transform 

Description:

This Snap converts binary data at the input view to a document data at the output view.

  • Expected upstream Snaps: Any Snap with a binary output view, such as File Reader, Multi File Reader, Hdfs Reader, CSV Formatter, and JSON Formatter.
  • Expected downstream Snaps: Any Snap with a document input view, typically a Snap which expects a binary data as a value of the "content" key in the input document data.
  • Expected input: Binary data.
  • Expected output: The output view provides the binary data as a byte array value to the "content" key in the output document data. If the input binary data contains header information, the meta data in the header will be present as a value to the key "original" in the output document data. One use case would be to connect a Salesforce Create Snap as a downstream Snap to upload an attachment to an SObject record.


Prerequisites:

[None]


Support and limitations:
  • Ultra pipelines: Works in Ultra Pipelines if Ignore empty string is not set.Spark mode: Not supported in /wiki/spaces/SD/pages/1437917 mode.
  • This Snap can receive multiple binary streams. If you select Encode or Decode > BYTE ARRAY, then the maximum limit for each input binary stream is 2GB. The limit is much lower for other options and depends on the pattern of the input data.
Account: 

Accounts are not used with this Snap.


Views:


InputThis Snap has exactly one document input view.
OutputThis Snap has exactly one document output view.
ErrorThis Snap has at most one document error view and produces zero or more documents in the view.


Settings

Label


Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.

Encode or Decode



Required. Select if the content should be encoded or decooded. The options are:

  • ENCODE_BASE64
  • DECODE_BASE64
  • DOCUMENT
  • BYTE_ARRAY
  • NONE

If the input "content" data has already been Base64-encoded and ENCODE_BASE64 is selected, the Snap will not encode the content again. In the same way, if the input "content" data has not been Base64-encoded and DECODE_BASE64 is selected, the Snap will not attempt to decode the content. The format option DOCUMENT allows you to serialize the document into a SnapLogic-specific JSON represenation, which allows you to deserialize types such as Dates when read back using a BinaryToDocument Snap.

BYTE_ARRAY is used to pass raw binary data.  For example, a compressed .zip file can be created in many formats.  The safest way to convert such a file between binary and document is with BYTE_ARRAY.

When NONE is selected, the Snaplex's default platform specific encoding is used.This can be used for string text such as a .xml or a .csv format.  Because this uses platform specific encoding, it can vary between Snaplexes; therefore it is not advised to use NONE when passing data between pipelines that may be running in Snaplexes which run different operating systems.

Info
  • This Snap can receive multiple binary streams. If you select Encode or Decode > BYTE ARRAY, then the maximum limit for each input binary stream is 2GB. The limit is much lower for other options.

  • Depending on the input data, the encoded/decoded data can become larger than 2GB, even if the input data is smaller than 2GB.


Example: BYTE_ARRAY
Default value:    ENCODE_BASE64  

Ignore empty stream


If selected, the Snap will do nothing when no document has been received in the input view.
If not selected, the Snap will write empty binary data with a header at the output view when no document has been received in the input view.

Example: Selected

Default value: Not selected 


Multiexcerpt include macro
nameSnap Execution
pageAnaplan Read


Multiexcerpt include macro
nameSnap_Execution_Introduced
pageAnaplan Read

Example


Uploading a PDF File Attachment to a Salesforce Account Record

To upload a PDF file attachment to a Salesforce Account record, prepare a pipeline of File Reader Snap + Binary to Document Snap + Mapper (Data) Snap + Structure Snap + Salesforce Create Snap.

  • File Reader Snap: Enter a pdf file URL in the File property.
  • Binary to Document Snap: Select "ENCODE_BASE64" for the Encode or Decode property.
  • Mapper (Data) Snap: Enter one row of "$Id" in the Target path property and an ID of an existing Account SObject record.
  • Structure Snap:  Mapping table property

     Source path Operation  Target path
     $original.content-location move $Name
     $Id move $Id
     $original.content-type  move $ContentType
     $content move $Body


  • Salesforce Create Snap: Enter "Attachment" in the Object type property.



The following pipeline reads the binary data from the upstream and converts it into document data in the output preview. 

The File Reader Snap reads the binary data to be converted:

The output preview when ENCODE_BASE64 is selected:



The output preview when DECODE_BASE64 is selected:


The output preview when NONE is selected:

The output preview when DOCUMENT is selected:


The output preview when BYTE_ARRAY is selected:

Insert excerpt
Transform Snap Pack
Transform Snap Pack
nopaneltrue