Forum Discussion

mtran21's avatar
mtran21
New Contributor III
6 years ago
Solved

Download all files from SFTP to a folder

Hi, I want to download all the files in a remote SFTP server to the Files folder. I think this is a pretty simple task but I am new, so I am not sure what to do.
So I am thinking of using these 2 snaps

but I have problem about the output file names. If on my remote server has file1.txt, file2.txt, file3.txt then I want to download the exact file names to my files folder.

What do I put in the file name?

Thanks

  • The output file should be decrypted already, but with the encrypted filename.$['content-location'] will be the url of the encrypted file because File Writer is connected to PGP Decrypt.

    You could replace or append the file extension if you know what the original extension is.

    • .replace('pgp', 'txt')
    • + ".txt"

3 Replies

  • You could use the following expression to get the filename from the input header.
    $['content-location'].substr($['content-location'].lastIndexOf('/') + 1)

    $['content-location'] represents the absolute path of the input file and the expression will remove everything from the beginning to the last forward slash.

    • mtran21's avatar
      mtran21
      New Contributor III

      Thanks for your help @siwadon

      If I want to decrypt all the encrypted files from FTP server before I download them to my files folder, I added the Decrypt snap as below

      but when I run it, the downloaded files are still with extension PGP. They are not decrypted.

      How do I decrypt them?

      • siwadon's avatar
        siwadon
        Employee

        The output file should be decrypted already, but with the encrypted filename.$['content-location'] will be the url of the encrypted file because File Writer is connected to PGP Decrypt.

        You could replace or append the file extension if you know what the original extension is.

        • .replace('pgp', 'txt')
        • + ".txt"