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.

1 Answer 1


The ContentVersion and ContentDocument objects don't store MIME types. They do, however, store a FileType, 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.

  • Is there some place where there would be a list of possible values?
    – zaitsman
    May 10, 2019 at 4:51
  • 1
    @zaitsman Not that I am aware of. It's a String field and I've never seen documentation of the slate of available values.
    – David Reed
    May 10, 2019 at 11:35
  • 1
    not like it's an extensive list, but at least some are here: developer.salesforce.com/docs/atlas.en-us.api_meta.meta/…
    – zaitsman
    Feb 25, 2021 at 2:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.