2
我在頁面上點擊鏈接時想要打開外部docx文件。不幸的是fs.readFile只能讀取本地路徑。使用fs.readFile從外部URL獲取文件
我試圖
app.get('/getfile', function (req, res) {
var externalURL = 'http://www.examplesite.com/example.docx';
// var externalURL = req.query.external;
fs.readFile(externalURL, function(err, data) {
var fileData = new Buffer(data).toString('base64');
res.send(fileData);
});
});
不要使用您已發佈 –
SCRIPT7002代碼時,你得到什麼錯誤/輸出網絡錯誤0x2efd,無法完成該操作由於錯誤00002efd。 –
是有用的嗎?標記爲解決該問題。 –