Flask send_file inline not working as expected

Viewed 76

Generating a PDF report in Flask and sending the file to the client using:

send_file(file,as_attachement=False)

On the React JS end I have a function the handles the PDF file: Using Axios:

const receiveFile = (data) => {
    if (data.data) {
        let url = window.URL.createObjectURL(new Blob([data.data]));
        let link = document.createElement("a");
        link.href = url            
        link.setAttribute("download", data.filename)            
        document.body.appendChild(link)
        link.click()
        document.body.removeChild(link)
    }
}

The file gets sent without issue and the receiveFile received the data properly; however, my browser is set to open PDF files. Instead I am being asked to download it. How do I fix the code so the browser displays the PDF when it is received.

0 Answers
Related