primeng
primeng copied to clipboard
fileupload : the image source is only from current window for external loaded files
I already implemented a way to load the files from backend to view them in the file uploader
<p-fileUpload [files]="galleryImages" multiple="multiple" accept="image/*"></p-fileUpload>
galleryImages array of File where we will pass it to fileUplaod component
The images comes from the backend as array of of fullpath of the image as string images: string[]
_getGalleryImages(images: string[]) {
const galleryImages: File[] = [];
images.map((galleryImage) => {
this.getImageAsBlob(galleryImage).subscribe((res) => {
console.log(res);
const blob = res;
const filename = galleryImage.replace(/^.*[\\\/]/, '');
const file = new File([new Blob([blob])], filename, { type: 'image/png' }) as any;
galleryImages.push(file);
});
});
//some delay to prepare the array to fileupload compnent
setTimeout(() => {
this.galleryImages = galleryImages;
}, 1000);
}
The uploader is initialised with the images from backend but the the image preview is broken

This issue is solved by getting the right blob data, I closed this is issue but its good for : Listing previously uploaded files in Edit mode