No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Download file served by API

    Help
    1
    2
    1330
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nobilik last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • N
        nobilik last edited by

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

        this.$axios.post('/route/' , { data: data }, { responseType: 'blob' })
            .then((response) => {
              const status = exportFile('test.xlsx', response.data)
              if (status === true) {
                console.log('ok')
                // browser allowed it
              } else {
                // browser denied it
                console.log('Error: ' + status)
              }
            })
        1 Reply Last reply Reply Quote 0
        • First post
          Last post