无法使用filesaver.js打开下载的文件
错误:PowerPoint在abc.pptx中发现内容有问题无法打开文件,文件可能被损坏。
客户端代码(使用filesaver.js保存文件)
$http.get(url) .then(function(resp) { var file = new Blob([resp.data], {type : 'application/vnd.openxmlformats-officedocument.presentationml.presentation'}); saveAs(file, "abc.pptx"); }, function(error) { return $q.reject(error.data.message); });
服务器端代码
app.get('/..', function (req, res) { stream = fs.createReadStream(filePath); stream.pipe(res); });