I have file from UploadedFile button, and I want to print the extension files by use in magic number,
My code:
UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();
byte[] fileByteArray = IOUtils.toByteArray(file.getInputStream());
pay attention: Mime type and content file (from file and from the filename) not same to magic number (magic number comes from the first bytes of the inputStream)
How can I do it?
I know this is an old question, just put my answer here hopefully someone finds it useful when searching for the same solution.
References for file magic numbers: