Visual Builder

Get Involved. Join the Conversation.


    Ashish Solanki
    How to download file form SFTP using VBCS
    Topic posted August 26, 2019 by Ashish SolankiRed Ribbon: 250+ Points, tagged JET, REST 
    46 Views, 2 Comments
    How to download file form SFTP using VBCS
    How to download file form SFTP in VBCS

    Hi All,

       We have requirement to give option to user -  like link / button at  VBCS  page to download a file from SFTP. 

       We are planning to upload the file at SFTP using ICS adapter, which we will call from VBCS. But not sure about how to give option/link  to  user to download the same file from SFTP. 

    If anyone has done it previously then please share the code.

    Thanks in Advance.

    With Regards,

    Ashish Solanki






    • David Konecny

      I wrote an app which allowed to download a text file which was relatively small. The "Download" button would call action chain which would call this custom JS function:

      * Workaround to download generated spec file. The workaroud adds dynamically invisible <A> link
      * into document, clicks on the link to trigger it and removes it again. The link URL is data: url
      * which allows to embed generated file content into the link itself. See
      * for more details.
      */ = function(fileName, specFileContent) {
      var element = document.createElement('a');
      element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(specFileContent));
      element.setAttribute('download', fileName);
     = 'none';

      You could try something similar where you first fetch the file content into browser into ByteArray, then base64 encode it and set it as base64 data URI and simulate click event on it. It will work fine on small/er files.

      Best solution would be for the backend, the SFTP, to return you a file specific readonly unique link which expires and just display the link in your web page.


      • Ashish Solanki

        Hi David,

          Thanks for your response. I will use try the solution suggested by you and confirm. Thanks again!!

        With Regards,

        Ashish Solanki