Sha256: b887578348f206f47745d1d3a1291ef79e8b6b8ff43bb767f9d07abf3f6ed263
Contents?: true
Size: 985 Bytes
Versions: 2
Compression:
Stored size: 985 Bytes
Contents
= grip GridFS attachments for MongoMapper = installation The grip gem is hosted on gemcutter.org: * gem install grip = Usage class Foo include MongoMapper::Document include Grip has_grid_attachment :image, :versions => {:thumb => {:width=>50,:height=>50}} has_grid_attachment :pdf # Hook for resizing or whatever gets you there. # any specified options are passed back to you # at this point. # Just return the file when you're done. def process_image opts puts "processing" opts[:file] end end image = File.open('foo.png', 'r') pdf = File.open('foo.pdf', 'r') foo = Foo.create(:image => image, :pdf => pdf) foo.image # contents read from gridfs for serving from rack/metal/controller foo.image_name # foo.jpg foo.image_content_type # image/png foo.image_size # File.size of the file foo.image_path # path in grid fs foo/image/:id where :id is foo.id
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grip-0.5.1 | README.rdoc |
grip-0.5.0 | README.rdoc |