Vahid Ansari
Vahid Ansari

Reputation: 1

Migratiom from paperclip to carrierwave - uploading attachment to amazon S3

my rails application attachments were on paperclip after migration to carrierwave i want to keep old attachments uploaded to amazon S3 so i tried attachments urls be in this format: "https://static.tagmond.com/static.tagmond.com/stores/banners/000/000/032/original/cover_large_app_2.jpg"

so i added below method to carrierwave uploader

    def paperclip_path
     'stores/banners/:id_partition/:style/:basename.:extension'
    end

but i got issue on carrierwave initializer config file

here is my config file in carrierwave.rb: {

CarrierWave.configure do |config|
  config.storage = :fog
  config.fog_provider = 'fog/aws'
  config.fog_credentials = {
    provider: 'AWS',
    aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
    aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
    region: ENV['AWS_REGION'],  //"eu-north-1"


    
    # host: ENV['S3_HOST_NAME'], //"aws.tagmond.com"
    # endpoint: "https://static.tagmond.com"
  }
  config.fog_directory  = ENV['S3_BUCKET_NAME'] //"static.tagmond.com"

}

I dont exactly know which combination of these three host, endpoint & fog_directory gives me the answer. despite url format i have problem with uploading to S3 it keeps giving me this error:

[fog][WARNING] fog: the specified s3 bucket name(static.tagmond.com) contains a '.' so is not accessible over https as a virtual hosted bucket, which will negatively impact performance. For details see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/BucketRestrictions.html

I tried raising issue in carrierwave and fog at github

Upvotes: 0

Views: 34

Answers (0)

Related Questions