rethinkdb / rethinkdb

The open-source database for the realtime web.
https://rethinkdb.com
Other
26.76k stars 1.86k forks source link

Save mime-type in binary if we know it #3192

Open deontologician opened 10 years ago

deontologician commented 10 years ago

When grabbing a file with r.http:

r.http('gravatar.com/avatar/0b1129eaca8152c556c200cd8d179187', {resultFormat: 'binary'})

We could save the mime-type in the binary pseudotype document:

{
"$reql_type$": "BINARY",
"data": ...
"mime": "image/png"
}

This wouldn't try to do any autodetection, just store what we were told by the remote server. We could also add mime term for getting and setting the mime-type manually, like:

some_binary.mime()
some_binary.mime('image/png')

Basically, I ran into this trying to use binaries in earnest today. I ended up needing to always store the mime-type alongside. It'd be nice to have rethinkDB handle that automatically.

danielmewes commented 10 years ago

I think some_binary.mime() should only be for getting the mime type, not for setting it. For setting a mime type, we could add an opt arg {mime: ...} to the r.binary() constructor.

Putting into subsequent. Let's discuss this more in the next ReQL discussion period.