How to retrieve media extention (for example .pdf , .jpg , .dockx) from filedocument retrieved by a GET?

0
Hello,  I have a universal file viewer in my mendix application where i want to load & show binary’s from an external web service by a rest GET action. but when it returns the object FileDocument it has the name “file" so i can’t extract nothing from it : PLEASE IGNORE THE ‘FILETYPE’ as it’s added custom. Anyone knows a good way to retrieve the file extension (.pdf , .jpg , .csv ….) from a fileDocument retrieved as a get?
asked
2 answers
1

It depends on what information your external service is providing, but often webservices provide additional information in the headers. You can try to call the webservice using Postman and investigating the response headers to see if they return any information. Alternatively, check with your external service provider if they can supply this information with the request.

An example of a webservice I'm using:

answered
0

With some custom Java you would be able to get as much as the mime type (https://stackoverflow.com/questions/51438/how-to-get-a-files-media-type-mime-type#847849), which would still not give you the file extension.

If you could receive the file name from the external resource then you could use a RegEx to extract the file extension from the name...

answered