Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the correct way to determine content type? #388

Open
OmarShehata opened this issue Oct 13, 2019 · 3 comments
Open

What's the correct way to determine content type? #388

OmarShehata opened this issue Oct 13, 2019 · 3 comments

Comments

@OmarShehata
Copy link

The spec says:

Explicit file extensions are optional. Valid implementations may ignore it and identify a content's format by the magic field in its header.

https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#file-extensions-and-mime-types

These two sentences seem contradictory to me. If the file extension is option, then a valid implementation must use the magic field, right?

@ptrgags
Copy link
Contributor

ptrgags commented Aug 8, 2020

This question came up again when working on some internal details of the ion platform. I had a case where I wanted to download files from a tileset for comparison, following external tileset links. This leads to questionable code since I either make assumptions about filenames or have to download large files just to check the first couple of bytes.

@mramato suggested this solution in another issue:

One possible solution is for there to be a mimeType or similar property that lives next to the uri. So "mimeType": "application/json" would tell you what uri is.

@lilleyse
Copy link
Contributor

Other thoughts:

CC #341 and #555

@javagl
Copy link
Contributor

javagl commented Jun 12, 2023

Sticking to the word from the quote of this issue (that is still in the specs now, 4 years later), the sentence

Valid implementations may ignore it and identify a content's format by the magic field in its header.

should probably have been reworded.

On a technical level, there are different options for determining the content type, roughly:

  • The file extension: That's simple. But as most simple solutions, it's broken. Don't do this.
  • Something that hasn't been mentioned here: The transport layer. One could rely on the Content-Type of some HTTP header. But this is only an option, and requires the MIME types to be registered, configured properly, and ... does not work when working on the file system. So it cannot be part of the 'format specification'
  • An explicit content.mimeType property: This is not part of 3D Tiles 1.1, and could therefore only be added in 3D Tiles 2.0.
  • The magic header (or file content in general): That' works ... until you have to differentiate between a content.gltf file, a tileset.json, and a shape.geojson. If we ever publish 3D Tiles 2.0, then every valid 3D Tiles 2.0 tileset file will also be a valid glTF 2.0 asset 😕

So the options are

  • consider one source of information as the truth. This could only be the file content itself
  • consider multiple sources of information: What to do when these sources disagree?

A related discussion is in KhronosGroup/glTF#1966 , and the conclusion is that a specification can make recommendations or suggestions, but it's nearly impossible to specify a certain runtime behavior.

OK to close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants