i created a SPRING BOOT service which can store different type of files. when i tried to consume this service into ANGULAR , the images works as well but when i try to displ
You cant pass the blob file as src in pdf viewer, you have to convert it to safeUrl to preview. Hope this will help.
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; // import
constructor(private sanitizer: DomSanitizer) // include in constructor
if (this.retrieveResonse.fileType == "pdf") {
var blob = new Blob([this._base64ToArrayBuffer(this.base64Data)], {
type: "application/doc"
});
const url = URL.createObjectURL(blob);
this.retrievedFile = window.open(url);
the base64ToArrayBuffer methods:
_base64ToArrayBuffer(base64) {
const binary_string = window.atob(this.base64Data);
const len = binary_string.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes.buffer;
}