node.js axios download file stream and writeFile

前端 未结 8 992
花落未央
花落未央 2020-12-24 08:50

i want download a pdf file with axios and save on disk (server side) with fs.writeFile, i have tried:

axios.get(\'https://xxx/my.pd         


        
8条回答
  •  遥遥无期
    2020-12-24 09:17

    import download from "downloadjs";
    
    export const downloadFile = async (fileName) => {
        axios({
            method: "get",
            url: `/api/v1/users/resume/${fileName}`,
            responseType: "blob",
        }).then(function (response) {
            download(response.data, fileName);
        });
    };
    

    it's work fine to me

提交回复
热议问题