On Sat, Mar 12, 2011 at 11:29 AM, nishant nigam
[email protected]wrote:
Bryan i did those changes …i dont know how to change the main uploader
code from where the file will upload…
Everything is explained right in the documentation. If you installed
fog
and have an Amazon S3 account to provide as the fog credentials and fog
directory then following the below steps in the documentation is easy.
From
the Carrierwave documentation (GitHub - carrierwaveuploader/carrierwave: Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks):
Using Amazon S3
Fog http://github.com/geemus/fog is used to support Amazon S3. Ensure
you
have it installed:
gem install fog
Youll need to provide your fog_credentials and a fog_directory (also
known
as a bucket) in an initializer. You can also pass in additional options,
as
documented fully in lib/storage/fog.rb. Heres a full 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_directory’ #
required
config.fog_host = ‘https://assets.example.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
In your uploader, set the storage to :fog
class AvatarUploader < CarrierWave::Uploader::Base
storage :fog
end
Thats it! You can still use the CarrierWave::Uploader#url method to
return
the url to the file on Amazon S3.
and i also need to write the rspec test cases for the same…
You will need to write them yourself. That is the job you accepted for
the
client you are doing the work for. If you have errors in your tests or
errors when they run feel free to post the error you are getting to the
group for help in debugging.
B.