I'm using a REST api, that send me json data with file info (base64 content, mime...). I want to open PDF in Chrome. URL.createObjectURL is a bad solution because after redirection, we can't download the file.
So, as a backend, i want to change the header response to "application/pdf", and display file content directly.
I searched in HttpClient Interceptors module :
@Injectable()
export class DownloadInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).map(event => {
if (event instanceof HttpResponse) {
if (event.body) {
let fileContent, typeMime;
fileContent = event.body.cContenuFichier;
let headers = new HttpHeaders({
'Content-Type': 'application/pdf'
});
event = event.clone({ body: fileContent, headers: headers })
}
}
return event;
});
}
Now, how to display this ? If i use a component, file content is display in classic html page.
So, is it possible ? With angular ? With node ?
Many thanks,