Skip to content

Support direct file download/open without Blob handling #7061

@2707sukesh

Description

@2707sukesh
Image

Is your feature request related to a problem? Please describe.

Motivation

Currently, when downloading binary files (e.g., PDFs) with Axios, the only way is:

const response = await axios.post(url, data, { responseType: 'blob' });
const blob = new Blob([response.data], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);
window.open(url);

This works, but has 2 major drawbacks:

Filename loss: Blob objects don’t carry filenames. Even if the backend sends a Content-Disposition: attachment; filename="report.pdf" header, developers must manually parse headers and set link.download.

Extra complexity: Developers must create/revoke object URLs just to preview or download files. This is error-prone and not developer-friendly.

Describe the solution you'd like

A simpler way to open files in the browser directly, preserving backend headers.
For example:

// Hypothetical usage
const response = await axios.get(url, {
  responseType: 'file', // new type?
  openInBrowser: true,  // instruct Axios to hand off directly
});

or at least:

const response = await axios.get(url, { responseType: 'blob' });
window.open(response.nativeUrl); // Axios could expose a native URL + filename

Describe alternatives you've considered

No response

Additional context/Screenshots

It can be seen in the screen shot that the file name is something random when we download and also the file name shown in the Chrome PDF Viewer is also some invalid name ( its not the name of the actual file sent from the back end )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions