On this Page

Snap type:

Write 

Description:

The File Delete Snap deletes a file in the SLDB, S3, FTP, SFTP, FTPS, WASB, WASBS, GS, and SMB protocols.

  • Expected upstream Snaps: Any Snap that produces documents in the output view such as CSV Parser and JSON Parser.
  • Expected downstream Snaps: Any Snap that accepts documents in the input view such as CSV Formatter and JSON Formatter.
  • Expected input: The Snap expects to find values for the JSON paths used in the File property, if any.
  • Expected output: The file name and the delete status are written to the output view. The following example shows the output document map data:
{
        "file": "sldb:///sample.json",
        "status": "200 OK"
    }


Prerequisites:

None.

Support and limitations:Works in Ultra Task Pipelines.
Account: 

This Snap supports a Basic auth account, an AWS S3 auth account, SSH Auth account, SMB account, or no account. See Configuring Binary Accounts for information on setting up accounts that work with this Snap.

Views:


InputThis Snap has at most one document input view in which it might obtain values for the evaluation of the JavaScript expression in the File property.
OutputThis Snap has at most 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.

File

Required. Specifies the URL for the file to be deleted. It might start with a file protocol. The supported file protocols are SLDB, S3, FTP, SFTP, FTPS, WASB, WASBS, GS, and SMB protocols.
Example: sldb:///usr/john/json_files/accounts.json

Default value:  [None] 

When deleting a directory, ensure to empty its contents first (delete the files within the directory and then the directory folder itself). 


File delete action

Specifies the action that the Snap must take when the target file is not found during a file delete attempt. Select from the following options:

  • ERROR if file not found: The Snap writes an error to the error view.
  • IGNORE if file not found: The Snap writes the status 200 OK to the output view. 

Default value:  ERROR if file not found

Validate deletion


If selected, the Snap checks if the deleted file still exists.

Default value:  Not selected 

Number of retries

Specifies the maximum number of retry attempts in case of a network failure.


If the value is larger than 0, the Snap first downloads the target file into a temporary local file. If any error occurs during the download, the Snap waits for the time specified in the Retry interval and attempts to download the file again from the beginning. When the download is successful, the Snap streams the data from the temporary file to the downstream Pipeline. All temporary local files are deleted when they are no longer needed.

Ensure that the local drive has sufficient free disk space to store the temporary local file.


Minimum value: 0

Default value: 0
Example3

Retry interval (seconds)

Specifies the minimum number of seconds for which the Snap must wait before attempting recovery from a network failure.

Minimum value: 1

Default value: 1
Example3

Advanced properties

Use this field set to define additional advanced properties. This field set contains the following fields:

  • Properties
    • SAS URI
  • Values
SAS URI

If the SAS URI value is provided in the Snap settings, then the settings provided in the account (if any account is attached) are ignored.



Default Value: Execute only
Example: Validate & Execute

Example


Deleting a File from Your SnapLogic Database

The following pipeline describes a File Delete Snap that deletes a file from your SnapLogic database. The pipeline:


  1. Reads a file from your SnapLogic database using the File Reader Snap.
  2. Writes/Creates a new file in your SnapLogic database using the File Writer Snap.
  3. Passes the filename field to the File field of the File Delete Snap using the Mapper Snap.
  4. Deletes the newly created file, using the filename parameter, from your SnapLogic database using the File Delete Snap:

     

Similarly, in the above example, you can directly pass the filename in the File field of the File Delete Snap: 

The following File Delete Snap deletes a file that exists on an external server. You must link the File Delete Snap with a valid user account and ensure that the user account has the appropriate privileges to delete a file from an external server. In the following pipeline, the File Delete Snap uses valid FTP user account credentials to delete the test.csv file: