Download File in VBCS


  • Create a sample application which picks file and stores the same as Base64 data
  • Invoke below function to download the given file

PageModule.prototype.fileDownload = function(mimeType,base64Data,fileName){
      let file = 'data:'+ mimeType +';base64,' + base64Data;
      let encodedFile = encodeURI(file);
      let link = document.createElement('a');
      link.setAttribute('href', encodedFile);
      link.setAttribute('download', fileName);
      link.click();
    };


Note : This function has been tested with below Mime Types

Extensions Mime Type FileName
CSV text/csv Test.csv
DOC application/msword Test.doc
DOCX application/vnd.openxmlformats-officedocument.wordprocessingml.document Test.docx
HTML text/html Test.html
JPG image/jpeg Test.jpg
PDF application/pdf Test.pdf
PNG image/png Test.png
TXT text/plain Test.txt
XLS application/vnd.ms-excel Test.xls
XLSM application/vnd.ms-excel.sheet.macroEnabled.12 Test.xlsm
XLSX application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Test.xlsx
XML application/xml Test.xml

Comments

Popular posts from this blog

Mavenize an Oracle ADF Application

Creating Column Filter on a VBCS Table using ListDataProvider(LDP)

Using Custom Colors in Sunburst Chart