[Vuejs]-Convert FileReader.readAsText() result string back into a file object for download?

0đź‘Ť

âś…

Figured out the solution. Instead of doing fileReader.readAsText() I changed to fileReader.readAsDataURL() and then the download looks like this now

downloadFile() {
  var a = document.createElement('a')
  a.download = fileName
  a.href = fileData
  a.dataset.downloadurl = [a.download, a.href].join(':')
  a.click()
}

The issue was indeed the wrong data format in the beginning!

Leave a comment