I encountered an issue, that maybe some of you have answer for. I have a dashboard-like app running on MEVN Stack. I want the user to be able to upload his image and store it in backend server, because as I understood, it is not possible to upload to VueJS project public folder directly.
So I found a way to upload it thanks to some post I found here. But I cannot find a way back. My image is store on my backend server and I want to get it using axios in blob form and display it in VueJS. It should be pretty simple but there something I may missed.
First I get the name of my image file and send it like this with Express:
res.sendfile(path.join(__dirname,"../../images/societies/",result.img_link));
I also return a default image url if there is no image, which works fine, but not the fetched images. The problem is I cannot access the image directly using URL, it is not accessible. So I have to find a way to get it as a blob I guess and display it.
Here is the code I use to get my Image in frontend, VueJS (script part):
getSocietyImage(society) {
if(society.image){
this.$http
.get(this.apiUrl + "society/getImg/" + society.id)
.then(image => {
return image.data
})
.catch(err => {
console.log(err)
})
}else{
return this.basicImgUrl
}
}
Here is the code in the template part which is a part of a v-for directive:
<img
:src="getSocietyImage(society)"
alt="content-img"
class="responsive card-img-top"
/>
Below is what I get from the request from a console.log():

Thanks everyone for your help!