Я использую следующий.
Сервис
р>
Код: Выделить всё
obtenerDoc(nodeId: string, token: string) {
const url = `${environment.proxyConfig}${this.baseUrl}/nodes/${nodeId}/content?attachment=true&alf_ticket=${token}`;
const headers = new HttpHeaders({
'Authorization': `Bearer ${token}`,
'accept': 'application/octet-stream',
});
return this.http.get(url, {
headers: headers,
responseType: 'blob',
observe: 'response'
});
}
Код: Выделить всё
obtenerDocumentoNormal() {
this.obtenerDoc.obtenerDoc(this.nodeId, this.token).subscribe(
(response) => {
const contentDisposition = response.headers.get('content-disposition');
if (contentDisposition) {
const matches = /filename="(.+)"/.exec(contentDisposition);
const filename = matches && matches[1] ? matches[1] : 'desconocido.pdf';
}
const objectUrl = URL.createObjectURL(response.body);
this.nodoUrl = this.sanitizer.bypassSecurityTrustResourceUrl(objectUrl);
this.isImage = false;
this.isAudio = false;
this.isFrame = true;
this.isVideo = false;
this.isNotVisualizable = false;
this.isLoading = false;
},
(error) => {
console.error(error);
MessageUtil.showAlertMessage("No se puede visualizar este tipo de documento");
}
);
}
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/793 ... dom-string
Мобильная версия