2013-03-30 70 views
1

嗨我試圖上傳一些使用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 

感謝您的回答。

+0

請發佈您的代碼。 – Fa11enAngel

回答

1

瞎猜

:endpoint    => '' # optional, defaults to nil 

零≠'

所以只要刪除整個林,看看會發生什麼。我認爲正在發生的事情是試圖將一個空字符串附加到以'+'結尾的東西的末尾,然後是任何東西。

編輯:

從自己的文件

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 

在你的情況,你將需要區域,我相信來搭配,但我不認爲你會需要主機或端點。

+0

現在我得到這個錯誤:Except :: Errors :: SocketError在EventsController#創建 主機名與服務器證書不匹配 – user1796260

+0

從我可以看到我不認爲你需要聲明主機或嘗試刪除也。 – rovermicrover

+0

我已經刪除區域主機和enpoind,它現在正在工作:)非常感謝 – user1796260

相關問題