jnicklas/carrierwave-mongoid — Issue #30: feature: more options for gridfs
Author: banditj
Created: 2012-01-24 12:32:22+00:00
State: open

hi,

there s a new api for the current gridfs ruby driver (latest mongoid uses it)
http://mongotips.com/b/ruby-driver-gridfs-api-now-cleaner-and-faster/

and there are more options that can be set for storing the files.
http://api.mongodb.org/ruby/current/file.GridFS.html

sample:
# Saving IO data
file = File.open("me.jpg")
id2 = @grid.put(file,
:filename => "my-avatar.jpg"
:content_type => "application/jpg",
:_id => 'a-unique-id-to-use-in-lieu-of-a-random-one',
:chunk_size => 100 * 1024,
:metadata => {'description' => "taken after a game of ultimate"})

IMPORTANT: id2 = @grid.put(image, "my-avatar.jpg", :safe => true)

currently with latest mongoid i wasnt able to access the content-type
i had to save it manually to my model which includes the uploader

It would be great if we could define these options somewhere and that content-type works again.

best regards