Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MIME type for Flatbuffers?

I've searched to find the proper MIME type for flatbuffers but I can't seem to find any. No mention of it on their documentation either.

The project page: https://github.com/google/flatbuffers

like image 510
kewur Avatar asked Mar 27 '19 17:03

kewur


People also ask

What is a Flatbuffer file?

FlatBuffers is an efficient cross platform serialization library for C++, C#, C, Go, Java, Kotlin, JavaScript, Lobster, Lua, TypeScript, PHP, Python, Rust and Swift. It was originally created at Google for game development and other performance-critical applications.

How do FlatBuffers work?

FlatBuffers is a statically typed system, meaning the user of a buffer needs to know what kind of buffer it is. FlatBuffers can of course be wrapped inside other containers where needed, or you can use its union feature to dynamically identify multiple possible sub-objects stored.

How do you use Flatbuffer in C++?

FlatBuffers supports both reading and writing FlatBuffers in C++. To use FlatBuffers in your code, first generate the C++ classes from your schema with the --cpp option to flatc . Then you can include both FlatBuffers and the generated code to read or write FlatBuffers.


Video Answer


2 Answers

There is a similar question for protocol buffers, with a useful answer here: https://stackoverflow.com/a/48051331/761177

For flatbuffers something like application/x-flatbuffers;schema=x.y.z might be appropriate, where x.y.z is the namespace declared in your schema.

like image 117
Alistair Miles Avatar answered Sep 28 '22 14:09

Alistair Miles


There is none. The correct mime type to use is application/octet-stream.

I don't think creating one would make sense either, since a naked FlatBuffer (without knowledge of its schema) cannot be parsed (unlike JSON), it is an opaque binary file. application/flatbuffer (if it existed) is barely more useful than application/octet-stream.

You need the schema before the file becomes readable, and I don't think mime types have a way to specify the schema name.. though I suppose flatbuffers/schema-name would be cool, if whatever standards body governs mime types would allow it :)

like image 34
Aardappel Avatar answered Sep 28 '22 16:09

Aardappel