Skip to content

Loading…

feature: more options for gridfs #30

Closed
rand99 opened this Issue · 2 comments

2 participants

@rand99

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

@rmm5t
CarrierWave member

(I fixed the code formatting in the original issue)

Could you please elaborate on this a bit more? CW-Mongoid already uses the :content_type option when saving the file to GridFS.

@rmm5t
CarrierWave member

Closing this issue out. Please feel free to re-open with a failing test or pull-request.

@rmm5t rmm5t closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.