Web Api with ASP.NET CORE how to handle images

0

I have a web api in asp.net core and I use JWT to validate the requests with the api, my question is when we need to upload images, what is the best way to do it, since I currently keep the images in a folder of the api because if I upload them in wwwroot they would be available for any person and the idea is that only the people with the token have access, I was trying to get the images from a driver that is to say.

But the problem is that when I try to show it in the view I can not convert it to base64 since when I do the request if the image is displayed in developer tools in preview.

But when I try to convert the image to base64 it does not work for me since it returns me in the data of the following answer.

Try to use the data in the following way but do not make it work.

This is what is shown in the data of the image request

this.urlPhotoProfile I use to show an image in VueJS that is, but I can not get it to work.

There is a way to solve this, or another better solution for the treatment of the images.

Greetings ...

    
asked by Luis Ismael 30.08.2018 в 21:06
source

1 answer

0

I already managed to solve it. In case someone has the same problem, I append the solution to them

axios.get('api/Image/${this.IdPaciente}/125x125/${nameImage}',{ responseType: 'arraybuffer' })
    .then(response => {
         let imgBase64 = new Buffer(response.data, 'binary').toString('base64');
         let format = response.headers['content-type'];
         this.urlPhotoProfile = 'data:${format};base64,${imgBase64}';
     });
    
answered by 14.09.2018 в 08:57