【问题标题】:Download an epub file through axios & react-file-download lbraries in reactjs通过axios和react js中的react-file-download库下载epub文件
【发布时间】:2017-08-18 15:33:40
【问题描述】:

我正在尝试使用 axios 和 react-file-download 从我的服务器获取 epub 文件。下载代码如下-

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

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

【问题讨论】:

    标签: reactjs axios epub


    【解决方案1】:

    对于 epub 文件,内容类型类似于“application/epub+zip” 试试这个吧。

    谢谢 萨普塔

    【讨论】:

      【解决方案2】:

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

      您可能需要将 {responseType 'blob'} 添加到配置中 - 这就是我下载 PDF 文件的原因。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-11-17
        • 2020-02-26
        • 2021-06-25
        • 1970-01-01
        • 2019-10-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多