Sha256: a1810c78fc0e550241d2a07a32fbc55f1b64cf197f562360096c2c17cb628932

Contents?: true

Size: 1.44 KB

Versions: 6

Compression:

Stored size: 1.44 KB

Contents

class <%= model_constant %>Uploader < ApplicationController
  extend S3Multipart::Uploader::Core

  # Attaches the specified model to the uploader, creating a "has_one" 
  # relationship between the internal upload model and the given model.
  attach :<%= model %>

  # Only accept certain file types. Expects an array of valid extensions.
  accept %w(wmv avi mp4 mkv mov mpeg)

  # Define the minimum and maximum allowed file sizes (in bytes)
  limit min: 5*1000*1000, max: 2*1000*1000*1000

  # Takes in a block that will be evaluated when the upload has been 
  # successfully initiated. The block will be passed an instance of 
  # the upload object as well as the session hashwhen the callback is made. 
  # 
  # The following attributes are available on the upload object:
  # - key:       A randomly generated unique key to replace the file
  #              name provided by the client
  # - upload_id: A hash generated by Amazon to identify the multipart upload
  # - name:      The name of the file (including extensions)
  # - location:  The location of the file on S3. Available only to the
  #              upload object passed into the on_complete callback
  #
  on_begin do |upload, session|
    # Code to be evaluated when upload begins.
  end

  # See above comment. Called when the upload has successfully completed
  on_complete do |upload, session|
    # Code to be evaluated when upload completes                                                 
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
s3_multipart-0.0.10.6 lib/generators/s3_multipart/templates/uploader.rb
s3_multipart-0.0.10.5 lib/generators/s3_multipart/templates/uploader.rb
s3_multipart-0.0.10.4 lib/generators/s3_multipart/templates/uploader.rb
s3_multipart-0.0.10.3 lib/generators/s3_multipart/templates/uploader.rb
s3_multipart-0.0.10.2 lib/generators/s3_multipart/templates/uploader.rb
s3_multipart-0.0.9 lib/generators/s3_multipart/templates/uploader.rb