嗨我試圖上傳一些使用fogs和carrierwave s3的圖像。在我使用公共文件夾完成之前,我想把它放在一個桶裏。當我試圖上傳新的圖片,我得到: 在EventsController create
壞URI URI::InvalidURIError
(不URI?)使用carrierwave和霧上傳圖像到s3壞uri
我做了一些研究,並且可能來自一個「+」符號的名字,但我沒有任何「+」 這裏是我的參數要求:
> {"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"}
我已經按照從https://github.com/jnicklas/carrierwave 這裏的指示是一些代碼
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
和我的上傳:
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
感謝您的回答。
請發佈您的代碼。 – Fa11enAngel