Code Monkey home page Code Monkey logo

carrierwave_jquery_file_upload's Introduction

Description:

V5:

Sample app using Rails 3.1, carrierwave and V5 of jquery-file-upload to upload and store files on Amazon S3.

V4:

The old version of the app using Rails 3 and V4 of jquery-file-upload can be found here

The backgrounder branch delays the entire upload process to S3 thanks to carrierwave backgrounder and delayed job

Install:

  • Clone or fork the github repo
  • cd into app directory
  
    $: bundle install       #install required gems
    $: rake db:create:all   #create dbs
    $: rake db:migrate      #migrate db
    $: rails s              #start app
  

S3:

Since this app stores files to amazon S3 you will need an Amazon S3 account, otherwise you can choose to store images on your local filesystem by editing the uploader:

  
    #app/uploaders/image_uploader.rb
    # Choose what kind of storage to use for this uploader:
      storage :file     #stores files locally
    # storage :fog      #stores files on S3
  

Amazon S3 support is made possibile by Fog

You will need to tell carrierwave to use Amazons S3 by creating an initializer and providing your Amazon S3 authentication details:

  
    #config/initializers/carrierwave.rb
    
    CarrierWave.configure do |config|
      config.fog_credentials = {
        :provider               => 'AWS',                                      # required
        :aws_access_key_id      => 'amazon s3 access key',                     # required
        :aws_secret_access_key  => 'amazon s3 secret access key',              # required
        :region                 => 'us-west-1'                                 # optional, defaults to 'us-east-1'
      }
      config.fog_directory  = 'yourbucketname'                                 # required
      config.fog_host       = 'http://yourbucketname.s3.amazonaws.com/'        # optional, defaults to nil
      config.fog_public     = false                                            # optional, defaults to true
      config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}           # optional, defaults to {}
    end
  

Image Processing:

MiniMagick is app default for processing images; if you want to use another library, just edit the Gemfile and modify the uploader to reflect your choice:

  
    #app/uploaders/image_uploader.rb
    # Include RMagick or ImageScience support:
    # include CarrierWave::RMagick
      include CarrierWave::ImageScience
    # include CarrierWave::MiniMagick
  

References:

TODO:

  • testing

carrierwave_jquery_file_upload's People

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.