在reactjs中通过axios&react-file-download lbraries下载epub文件

在reactjs中通过axios&react-file-download lbraries下载epub文件

问题描述:

我试图从我的服务器上使用axios和react-file-download获取epub文件。下载代码如下所示 -在reactjs中通过axios&react-file-download lbraries下载epub文件

const FileDownload = require('react-file-download'); 
export const handleDownload = (url, bookName) => { 
    axios.get(url).then((res) => { 
    FileDownload(res.data, bookName+'.epub'); 
    }); 
} 

该文件已下载。我在光盘上看到不同尺寸的不同书籍。但他们只是不开放。我错过了什么?

对于epub文件,内容类型类似于“application/epub + zip” 请尝试此操作。

感谢 Saptha

Have a look at the responseType config option that axios provides.

您可能需要添加{responseType 'blob'}到配置 - 这是什么让下载的PDF文件为我工作。