<commit_before># CarrierWaveDirect

[![Build Status](https://secure.travis-ci.org/dwilkie/carrierwave_direct.png)](http://travis-ci.org/dwilkie/carrierwave_direct)

[CarrierWave](https://github.com/jnicklas/carrierwave) is a great way to upload files from Ruby applications, but since processing and saving is done in-process, it doesn't scale well. A better way is to upload your files directly then handle the processing and saving in a background process.

[CarrierWaveDirect](https://github.com/dwilkie/carrierwave_direct) works on top of [CarrierWave](https://github.com/jnicklas/carrierwave) and provides a simple way to achieve this.

## Compatibility

Right now, CarrierWaveDirect works with [Amazon S3](http://aws.amazon.com/s3/). Adding support for [Google Storage for Developers](http://code.google.com/apis/storage/) should be fairly straight forward since the direct upload form is essentially the same. Please see the contributing section if you would like support for Google Storage for Developers or any other service that provides direct upload capabilities.

Please be aware that this gem (and S3 in general) only support single file uploads. If you want to upload multiple files simultaneously you'll have to use a javascript or flash uploader.

## Information

More information, and how-tos [available on the wiki](https://github.com/dwilkie/carrierwave_direct/wiki)

## Installation

Install the latest release:

    gem install carrierwave_direct

In Rails, add it to your Gemfile:

    gem 'carrierwave_direct'

Note that CarrierWaveDirect is not compatible with Rails 2.

## Getting Started

Please read the [CarrierWave readme](https://github.com/jnicklas/carrierwave) first

CarrierWaveDirect works with [fog](https://github.com/geemus/fog) so make sure you have [CarrierWave](https://github.com/jnicklas/carrierwave) set up and initialized with your fog credentials, for example:

    CarrierWave.configure do |config|
      config.fog_credentials = {
        :provider               => 'AWS',       # required
        :aws_access_key_id      => 'xxx',       # required
        :aws_secret_access_key  => 'yyy',       # required
        :region                 => 'eu-west-1'  # optional, defaults to 'us-east-1'
      }
      config.fog_directory  = 'name_of_your_aws_bucket' # required
      # see https://github.com/jnicklas/carrierwave#using-amazon-s3
      # for more optional configuration
    end

If you haven't already done so generate an uploader

    rails generate uploader Avatar

this should give you a file in:

    app/uploaders/avatar_uploader.rb

Check out this file for some hints on how you can customize your uploader. It should look something like this:

    class AvatarUploader < CarrierWave::Uploader::Base<commit_msg>update fog link in readme to official repository<commit_after># CarrierWaveDirect

[![Build Status](https://secure.travis-ci.org/dwilkie/carrierwave_direct.png)](http://travis-ci.org/dwilkie/carrierwave_direct)

[CarrierWave](https://github.com/jnicklas/carrierwave) is a great way to upload files from Ruby applications, but since processing and saving is done in-process, it doesn't scale well. A better way is to upload your files directly then handle the processing and saving in a background process.

[CarrierWaveDirect](https://github.com/dwilkie/carrierwave_direct) works on top of [CarrierWave](https://github.com/jnicklas/carrierwave) and provides a simple way to achieve this.

## Compatibility

Right now, CarrierWaveDirect works with [Amazon S3](http://aws.amazon.com/s3/). Adding support for [Google Storage for Developers](http://code.google.com/apis/storage/) should be fairly straight forward since the direct upload form is essentially the same. Please see the contributing section if you would like support for Google Storage for Developers or any other service that provides direct upload capabilities.

Please be aware that this gem (and S3 in general) only support single file uploads. If you want to upload multiple files simultaneously you'll have to use a javascript or flash uploader.

## Information

More information, and how-tos [available on the wiki](https://github.com/dwilkie/carrierwave_direct/wiki)

## Installation

Install the latest release:

    gem install carrierwave_direct

In Rails, add it to your Gemfile:

    gem 'carrierwave_direct'

Note that CarrierWaveDirect is not compatible with Rails 2.

## Getting Started

Please read the [CarrierWave readme](https://github.com/jnicklas/carrierwave) first

CarrierWaveDirect works with [fog](https://github.com/fog/fog) so make sure you have [CarrierWave](https://github.com/jnicklas/carrierwave) set up and initialized with your fog credentials, for example:

    CarrierWave.configure do |config|
      config.fog_credentials = {
        :provider               => 'AWS',       # required
        :aws_access_key_id      => 'xxx',       # required
        :aws_secret_access_key  => 'yyy',       # required
        :region                 => 'eu-west-1'  # optional, defaults to 'us-east-1'
      }
      config.fog_directory  = 'name_of_your_aws_bucket' # required
      # see https://github.com/jnicklas/carrierwave#using-amazon-s3
      # for more optional configuration
    end

If you haven't already done so generate an uploader

    rails generate uploader Avatar

this should give you a file in:

    app/uploaders/avatar_uploader.rb

Check out this file for some hints on how you can customize your uploader. It should look something like this:

    class AvatarUploader < CarrierWave::Uploader::Base
{'fraction_non_alphanumeric': 0.08111988513998564, 'fraction_numerical': 0.002512562814070352, 'mean_word_length': 3.9231448763250882, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2783681', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1509, 'n_words': 568}