Hi I'm trying to upload some images on s3 using fogs and carrierwave. Before I did it in my public folders and I'd like to make it on a bucket. When I'm trying to uploads a new picture I get :
URI::InvalidURIError
in EventsController create
bad URI(is not URI?)
I've made some research and that could come from a "+" symbol in the name but I don't have any "+" here is my parameters request:
> {"utf8"=>"✓",
"authenticity_token"=>"ms48hFw8dTALEe543dPS0ywIdKynYvuAHMjiry7kghQ=",
"event"=>{"titre"=>"test des image avec S3",
"dday(1i)"=>"2013",
"dday(2i)"=>"3",
"dday(3i)"=>"30",
"lieux"=>"maison",
"commentaire"=>"aucune",
"pictures_attributes"=>{"0"=>{"name"=>"test",
"image"=>#<ActionDispatch::Http::UploadedFile:0xa35a14c @original_filename="image.jpg",
@content_type="image/jpeg",
@headers="Content-Disposition: form-data; name=\"event[pictures_attributes][0][image]\"; filename=\"image.jpg\"\r\nContent-Type: image/jpeg\r\n",
@tempfile=#<File:/tmp/RackMultipart20130330-26465-11z9gsf>>}}},
"commit"=>"Ajouter"}
I've followed the indication from https://github.com/jnicklas/carrierwave here is some code
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'xxx', # required
:aws_secret_access_key => 'xxx', # required
:region => 'eu-west-1', # optional, defaults to 'us-east-1'
:host => 'xxx.com', # optional, defaults to nil
:endpoint => '' # optional, defaults to nil
}
config.fog_directory = 'socialmausoleum' # required
config.fog_public = true # optional, defaults to true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
end
and my uploader:
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
# include Sprockets::Helpers::RailsHelper
# include Sprockets::Helpers::IsolatedHelper
# Choose what kind of storage to use for this uploader:
storage :file
storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
Thanks for your answears.
Shot in the dark
:endpoint => '' # optional, defaults to nil
nil ≠ ''
So just remove the whole lin and see what happens. What I think is happening is it is trying to append an empty string to the end of something ending up with a '+' followed by nothing.
Edit:
From their docs
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'
:host => 's3.example.com', # optional, defaults to nil
:endpoint => 'https://s3.example.com:8080' # optional, defaults to nil
}
config.fog_directory = 'name_of_directory' # required
config.fog_public = false # optional, defaults to true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
end
In your case you are going to need region I believe to match, but I don't think your going to need host or endpoint.