Hi ,
One common approach is to check the file's MIME type rather than solely relying on the file extension. MIME types provide a more reliable way to determine the file type regardless of the file extension.
Please check this answer, Hope this help:
https://community.mendix.com/link/space/java-actions/questions/112594