How to get the file's MIME type from box developer application using Box Java SDK ?

新規投稿

コメント

3件のコメント

  • Jason

    Hi ,

     

    Thanks for reaching out! Unfortunately we don't return MIME types. The extent of what we return is listed in the table/description of the file object here:

    https://developer.box.com/reference#file-object

     

    I'm curious to hear what your use case is for this? Additionally, has anyone else from the community here been looking for this too? If so, please let us know!

     

    Thanks,

    Jason

    0
    コメントアクション パーマリンク
  • Richard-Clark

    I just stumbled on this post while also looking for the way in which the Java SDK provides the file content type. It is surprising to find that this functionality isn't provided as it is a fundamental concept of HTTP resources. The storage services for both AWS and Azure support both specifying and retrieving resource content type through their respective Java SDKs.

     

    Snooping with dev tools in the browser I can see that the Content-Type is being set when I download a file. I do not know if you are storing the content type from upload or if you are just guessing it from the extension + content sniffing. It would be useful to expose the same content type via the file objects return from API.

     

    The simplest use case would be downloading a file from box and uploading to another service as a resource over a REST API. From box we'll need a minimum of the content type and content stream.

    0
    コメントアクション パーマリンク
  • dzlabs

    I would like to know the MIME type, I've case where I need to handle text files (e.g. CSV) vs binary ones (e.g. PDF) differently. Wonder if there is a way to get such information? I tried to use the `getExtension` but it's returning null in my case.

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。