Download file served by API

  • Hi! I’m trying to download xlsx file generated with my API, but the file is always corrupted.
    I use an Export File Util but downloaded file is almost two times bigger then original one and can’t be opened. With Postman the API response gives me expected result (the file is ok).
    So for experiment I’ve tried to download pdf file with Quasar and the result is the same (file was corrupted and two times bigger). But with .txt download is OK. I see that in axios response header “Content-Length” has a value that equals to original file size.
    Anybody knows how to fix this?

  • It was an Axios problem. Adding { responseType: 'blob' } fix it. Does anybody know how to get filename from response header?

    this.$'/route/' , { data: data }, { responseType: 'blob' })
        .then((response) => {
          const status = exportFile('test.xlsx',
          if (status === true) {
            // browser allowed it
          } else {
            // browser denied it
            console.log('Error: ' + status)

Log in to reply