I need to stream a file from Salesforce in our webapplication. To make sure the file is properly opened, I have to set Content-Type header.
How to retrieve the Content-Type (MIME) of a file?
I expect values like: image/png
, application/pdf
, text/html
etc.
How to get these values? I am using the Java and a SOAP client to retrieve the data.
Best Answer
The
ContentVersion
andContentDocument
objects don't store MIME types. They do, however, store aFileType
, which contains strings like "WORD_X", "PDF", and "POWER_POINT_X", which you could potentially map to MIME types. ("UNKNOWN" is also one value for this field).Additionally, the original file's
FileExtension
is stored on these objects and could be mapped in your code to a relevant MIME type.