0

I am trying to show a preview of attachments like if the user attaches an image preview will show IMAGE SVG, the same as PDF. I am decided preview by their base64 formate e.g for the image I use split method for image:

v-else-if="(image.split('/')[1].split(';')[0]) === 'png' || 'jpeg' || 'jpg'"

When I attach DOCS and PSD file, it shows me

data:application/octet-stream;base64,OEJQUwABAAAAA

Image Preview

How can I differentiate between docs and PSD to show a preview?

1 Answers1

0

base64 does not contain the file name. However, the only way to know the extension is by the file name. So you have to find an other way to get the file name. If you use an input[type=file], you can get the name by referring this answer.

Arthur Fontaine
  • 176
  • 1
  • 11