You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a user I'd like to be able to see my bookmark's favicons even when not online.
As a user I'd like to minimize the traffic sent to google because bandwidth is expensive in many parts of the world, and cell connections are slow in other parts of the world.
As a user I'd like the app to be as fast as possible with no unnecessary network calls slowing things down.
MongoDB 's mongoid ruby driver supports a BSON::Binary data type (elsewhere referred to as BinData). Which is good for files of less than 16Mb.
My thinking is:
when a bookmark is added 2 background jobs are spawned.
one to archive it
one to retrieve the favicon from google, using the current method, but in the background
the binary data is ingested from google, and stored in the db in a new Domain object.
the Bookmark model has_one: :domain (belongs_to ???) and the domain has a field :favicon, type: BSON::Binary
when a bookmark is loaded on the web page, the view queries the domain to see if it has a favicon in the db and uses it if it does.
Things I'm unsure about:
What's the incantation to ingest binary data into a db field?
classPhotosController < ApplicationControllerdefserve@photo=Photo.find(params[:id])send_data(@photo.data,# a binary column / field in your db. in our case BSON::Binary:type=>@photo.mime_type,:filename=>"#{@photo.name}.png",# but with dynamic suffix based on mime type :disposition=>"inline")endend
Storing
We probably need an Image model because we'd need to store mime type too (favicons can come in multiple types) and it wouldn't make any sense to store that on a Domain model.
Use cases:
MongoDB 's mongoid ruby driver supports a
BSON::Binary
data type (elsewhere referred to asBinData
). Which is good for files of less than 16Mb.My thinking is:
Domain
object.has_one: :domain
(belongs_to
???) and the domain has afield :favicon, type: BSON::Binary
Things I'm unsure about:
Serving
(example from here
Storing
We probably need an
Image
model because we'd need to store mime type too (favicons can come in multiple types) and it wouldn't make any sense to store that on aDomain
model.Routing
View
(
serve_photo_path
is because of the route defined above)How to Download
The text was updated successfully, but these errors were encountered: