16

I was building a little 3D-application using ThreeJS and WebGL. I purposely chose not to convert models into ThreeJS compatible .json files, instead started building an importer. It works, but I also planned to have the application decide what type of model has been loaded using both file extension and MIME type, the later if the first is unknown.

I've read somewhere that the MIME Type is supposed to be application/wavefront-obj, which would be kind of weird since there is also the model tree, but okay anyways. Though browsing the IANA website for this file type yields no results.

Am I missing something?

Yves M.
  • 29,855
  • 23
  • 108
  • 144
Kiruse
  • 1,703
  • 1
  • 12
  • 23
  • 1
    The only reference I could find by quick googling is [Wikipedia](http://en.wikipedia.org/wiki/Wavefront_.obj_file) which says `text/plain`. – tripleee Sep 05 '13 at 17:49
  • @tripleee Too vague for my need, but at least one confirmation I'm not missing something obvious... I guess I'll stick to the pseudo-MIME. Thanks anyways. – Kiruse Sep 05 '13 at 18:17

5 Answers5

14

According to wikipedia, it's text/plain for .obj.

I'm guessing it's text/plain for .mtl files as well, since there's text in them and since it "is a standard defined by Wavefront Technologies for ASCII files".

Yves M.
  • 29,855
  • 23
  • 108
  • 144
kangax
  • 38,898
  • 13
  • 99
  • 135
  • 1
    I know it's a standard for ASCII files, but it just seems too... ambiguous. The (automated) system I built decides how to parse resources based on different factors, one of which being the MIME type. Since it's an ASCII, there isn't any magic number I could rely on. Additionally, file handling in JavaScript isn't all that handy in the first place... I'll give this some more time, thanks for trying to attract more attention to this. Once the bounty expires, I'll mark this response as the answer. – Kiruse Oct 10 '13 at 19:39
  • Sure thing. I ran into this myself by making server gzip .obj files fetched via ajax (to save time and bandwidth). Need to know mime-type to specify it in nginx config. – kangax Oct 10 '13 at 20:09
  • And obviously `text/plain` isn't specific enough, just like my case. Although I don't think there really is anything else than that, maybe somebody has another solution. My case is satisfied by simply using a fake MIME, but I'm not sure about nginx. – Kiruse Oct 11 '13 at 13:36
  • Well, time's up. Time to mark this as solved. Thanks for your bounty offering anyways. – Kiruse Oct 19 '13 at 18:42
  • 2
    As of now, Wikipedia agrees with the updated IANA and it is `model/obj`. – coderforlife May 05 '21 at 17:27
3

You need to update your web.config and add the reference to the obj file type

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
      <staticContent>         
            <remove fileExtension=".obj" />
            <mimeMap fileExtension=".obj" mimeType="text/plain" />
      </staticContent>
   </system.webServer>
</configuration>
Yuriy A.
  • 750
  • 3
  • 19
3

Use MIME type application/object for .obj files. It works in Chrome, Safari, and FireFox.

Yves M.
  • 29,855
  • 23
  • 108
  • 144
Cliff Hall
  • 723
  • 6
  • 13
2

I was surprised to see nothing in the IANA database for wavefront obj files, considering that they've been kicking around the internet for 20 years at least. I'd be happy to collaborate with others in establishing an official MIME type.

Until then, according to section 3.3 of RFC 6838, "Personal or Vanity Tree", you can use your own media type for this, something like text/prs.wavefront-obj, in addition to text/plain. That way you can use the HTTP Accept header to negotiate the appropriate MIME type in your response.

Community
  • 1
  • 1
legalize
  • 2,214
  • 18
  • 25
  • I was surprised it was hard to find something in this regard in general. I suppose .obj is somewhat outdated, but its simplicity surely finds application somewhere. – Kiruse Apr 02 '15 at 10:00
  • I don't think obj is outdated at all. It is a very usable "common ground" format for geometry between many applications. – legalize Apr 02 '15 at 17:24
  • Yes indeed. That's why I specifically said somewhat outdated. The only features I think are lacking is dynamics and physics. It is designed for static models only thus it's value for animations obviously is fairly low. In this regard naturally one would favor a different format. The physics aspect goes hand in hand with the previous. – Kiruse Apr 12 '15 at 11:47
2

According to IANA, the association who defines and maintains media-types (this is not Wikipedia), the mime-type of "obj" is model/obj, and model/mtl for "mtl". See other media types for models: https://www.iana.org/assignments/media-types/media-types.xhtml#model

Daniel-KM
  • 174
  • 1
  • 1
  • 13