CesiumGS / 3d-tiles

Specification for streaming massive heterogeneous 3D geospatial datasets :earth_americas:
2.1k stars 466 forks source link

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

Open OmarShehata opened 4 years ago

OmarShehata commented 4 years ago

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 commented 4 years ago

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 commented 2 years ago

Other thoughts:

CC https://github.com/CesiumGS/3d-tiles/issues/341 and https://github.com/CesiumGS/3d-tiles/issues/555

javagl commented 1 year ago

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:

So the options are

A related discussion is in https://github.com/KhronosGroup/glTF/issues/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?