Help Regarding Amazon S3 and Career Wave along with Rspec

hello Guys,
i would like to know some details regarding how to implement AMAZON S3
with Career Wave in Rails 3.0.3 and i have to write Rspec test Cases
as well . Actually i already have code which is implemented with
Career Wave its a image uploading code and i need to change that code
on AMAZON S3. Can you guys help to me to make those changes and in
writing RSpec test Cases.Its really important and urgent..

Thanks
Nishant

Are you talking about Carrierwave? If you are then you can try the documentation for it which discusses everything you would like to do.

https://github.com/jnicklas/carrierwave

B.

Hey Bryan i have checked the link which you have given but i am not getting it, like the code i have is already created in Career Wave and i need to change that code and made up for Amazon S3 and have to write the code for rspec

I don’t know of any application called Career Wave. I thought you meant Carrierwave and had misspelled it by accident. The link I sent was for Carrierwave. Sorry for the confusion.

B.

Bryan, I am talking about the same thing i would like to use that one for avatar uploading of users that code is currently in Carrierwave and i wanted to change that code with S3 amazon there is a section of s3 in that link but i am not getting it…

like i have made changes in the storage to S3 previously it was file and made lots of changes but client not satisfied…

any help would be much appreciated…

Do you have an Amazon S3 account? Have you loaded the fog gem (https://github.com/geemus/fog) and done the other configurations that Carrierwaves instructions has specified? “You’ll 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”

B.

Bryan i did those changes …i dont know how to change the main uploader code from where the file will upload… and i also need to write the rspec test cases for the same…

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 (https://github.com/jnicklas/carrierwave):

Using Amazon S3

Fog is used to support Amazon
S3. Ensure you have it installed:

gem install fog

You’ll 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. Here’s 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](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

That’s 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.

Thanks Bryan…