MIME Type of Wavefront's OBJ and MTL
Asked Answered
A

5

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?

Allopath answered 5/9, 2013 at 16:44 Comment(2)
The only reference I could find by quick googling is Wikipedia which says text/plain.Wentworth
@Wentworth 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.Allopath
I
15

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".

Intolerable answered 10/10, 2013 at 19:16 Comment(5)
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.Allopath
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.Intolerable
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.Allopath
Well, time's up. Time to mark this as solved. Thanks for your bounty offering anyways.Allopath
As of now, Wikipedia agrees with the updated IANA and it is model/obj.Shrapnel
E
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>
Eastman answered 18/11, 2016 at 15:24 Comment(0)
E
3

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

Euphemie answered 22/6, 2017 at 22:59 Comment(0)
J
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.

Jalisajalisco answered 31/3, 2015 at 1:34 Comment(3)
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.Allopath
I don't think obj is outdated at all. It is a very usable "common ground" format for geometry between many applications.Jalisajalisco
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.Allopath
M
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

Monody answered 14/4, 2021 at 9:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.