Sha256: 7c9be686931fddff3e1c1a6ed6a31f252d615987e156cab7d662aa08cb6543fd

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 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, :resize => {: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

1 entries across 1 versions & 1 rubygems

Version Path
grip-0.4.4 README.rdoc