8
Tôi có webApi trả lại cho tôi một tệp blob mà tôi phải hiển thị. làm cách nào để biết loại blob mà tôi nhận được? Có thể là bất kỳ thứ gì, pdf, doc, jpeg, v.v.
$http({ method: 'GET', url: (itemsUrl), responseType: 'arraybuffer' }).then(function mySucces(res) {
var byteArray = res.data;
byteArray = new Uint8Array(byteArray);
var file = new Blob([byteArray], { type: '??????' });
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
});
hoặc, làm cách nào để mở blob trong cửa sổ mới mà không biết loại tệp?