200
Views
5
Comments
Solved
How to check binary file is image or not?

Hii, i am creating an application where i want to check that the binary file is image or not if not then provide a download option .

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Hi Prashant,

It's a bit silly to say "I don't want to use a Forge component", as Forge assets are explicitly meant to extend the OutSystems Platform in case there's no standard functionality that covers your requirements, and in case you cannot write the code yourself.

As for images, there are a couple of possibilities. The easiest is, like Nash wrote, to check the file name and see if it's a known image file extension. You could also write an extension (since you do not want to use Forge assets) that investigates the file header, and checks whether it contains signatures of known image file types. Since basically nowadays there's JPEG and PNG (and perhaps GIF and BMP) to worry about and not much else, this should be doable.

UserImage.jpg
Alexandre Yip

Hi Prashant Bais, 

Please check this forge component it might be suitable for your purpose

https://www.outsystems.com/forge/component-overview/6901/getmimetypes-by-magic-numbers

Hope that it helps you 

2025-03-04 14-45-15
Andre Sousa

Hello Prashant,

You can check this component to see if you can work around.

https://www.outsystems.com/forge/component-overview/7202/file-type-file-extension


Best Regards

2023-07-24 09-06-17
Prashant Bais

I don't want to use any forge component i want on click of paper clip icon if image then open pop up otherwise download the image 

testUploadExcel (1).oml
2025-06-03 14-12-42
Nash Muylle

Hi Prashant,


I do not think you will be able to check if the binary of a file is an image without using a forge component or creating an extension yourself.

However you could check the filename if it holds the extension of the file. So for example if the filename ends on .png or .jpg you could show the image element and otherwise download the file. But you will need to make sure that the filename holds the extension.


Hope this give some more insights!
Nash

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Hi Prashant,

It's a bit silly to say "I don't want to use a Forge component", as Forge assets are explicitly meant to extend the OutSystems Platform in case there's no standard functionality that covers your requirements, and in case you cannot write the code yourself.

As for images, there are a couple of possibilities. The easiest is, like Nash wrote, to check the file name and see if it's a known image file extension. You could also write an extension (since you do not want to use Forge assets) that investigates the file header, and checks whether it contains signatures of known image file types. Since basically nowadays there's JPEG and PNG (and perhaps GIF and BMP) to worry about and not much else, this should be doable.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.