1
我成功地使用varbinary(MAX)數據類型在數據庫中保存了文件(.txt,.docx,.pdf)。無法在angularjs中將.docx轉換爲blob
現在我使用下面的代碼從數據庫中下載文件。 我可以毫無問題地下載.txt擴展名文件。 當我試圖下載.docx擴展文件不按預期工作。因爲我們發現其內容「」存在問題,因此垃圾字符和word文檔無法打開。
$http(request).success(function (d, status, headers) {
head = headers();
var contentType = head['content-type'];
var contentdisposition = head['content-disposition'];
var fileName = contentdisposition.split(';')[1].trim().split('=')[1];
fileName = fileName.replace(/"/g, '');
console.log('calling');
var contentType = head['content-type'];
var data = d;
var file = new Blob([data], { type: contentType });
saveAs(file, fileName);
})
.error(function() {
});
需要設置的dataType的要求配置......看到文檔 – charlietfl
嗨Charlietfl,能否請你解釋一下如何在請求配置設置的dataType? –
它在'$ http'文檔中有解釋docs – charlietfl