我正在尝试执行文件下载,但所有下载的文件都已损坏(图像)或为空(pdf)

I'm trying to implement a file download, but all the downloaded files are either corrupted(image) or empty(pdf)

我正在尝试执行文件下载,但所有下载的文件要么已损坏(图片),要么为空文件(pdf)。我做错了什么?

axios.post(`/master/api/Download?filename=${rowData.fileName}&&FolderName=${folderName}&&ext=${rowData.fileExtension}`, {
        headers: {
          'Content-Type': 'application/json',
        },
        }).then(function(res) {
            var blob = new Blob([res.data], {
                  type: `application/${extension}`,
                });
            saveAs(blob, fileName );
        });

您需要调用 axios.get(...) 来获取下载的文件,因为调用 axios.post 正在尝试将数据发送到服务器