使用carrierwave上传S3时的BAD URI

时间:2015-06-05 01:10:29

标签: ruby-on-rails amazon-s3 carrierwave

尝试使用S3和carrierwave上传图片时出现以下错误,无法解决问题。

URI::InvalidURIError (bad URI(is not URI?): ://s3.amazonaws.com:):
      app/controllers/shops_controller.rb:38:in `block in update'
    app/controllers/shops_controller.rb:37:in `update'

在我的店铺控制器(第35至46行):

    def update
      @shop = Shop.find(params[:id])
    respond_to do |format|
      if @shop.update(shop_params)
        format.html { redirect_to "/sushiadmin", notice: 'Se ha editado el plato.' }
        format.json { head :no_content }
      else
        format.html { render action: 'edit' }
        format.json { render json: @shop.errors, status: :unprocessable_entity }
      end
    end
  end

我的S3配置(Production.rb)

  CarrierWave.configure do |config|
  config.fog_credentials = {
    provider: 'AWS',
    aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
    aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
    region: 'eu-west-1',
    :endpoint => 's3-eu-west-1.amazonaws.com'
  }

    config.fog_directory  = ENV['AWS_S3_BUCKET']
  end

////////////////修改

PARAMS-LOGS

2015-06-05T12:22:19.273490+00:00 app[web.1]: Started PATCH "/shops/1" for 80.30.158.93 at 2015-06-05 12:22:19 +0000
2015-06-05T12:22:19.277373+00:00 app[web.1]: Processing by ShopsController#update as HTML
2015-06-05T12:22:19.277485+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"t5UqatONHUmLhrGzMvj8HXHgcu2KLSGe8cLoEN3rgJs=", "shop"=>{"name"=>"C.C.Itaroa", "city"=>"", "direction"=>"Calle Intxaurdia 5, 31620, Huarte", "cover"=>#<ActionDispatch::Http::UploadedFile:0x007f26188839d0 @tempfile=#<Tempfile:/tmp/RackMultipart20150605-3-zm7xcj>, @original_filename="45.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"shop[cover]\"; filename=\"45.png\"\r\nContent-Type: image/png\r\n">, "printer_url"=>"192.168.1.1", "latitude"=>"", "longitude"=>"", "email"=>"navarra@mysite.es", "pc"=>"31016,31486,31600,31610,31620,31621,31699"}, "commit"=>"Editar", "id"=>"1"}
2015-06-05T12:22:20.004896+00:00 app[web.1]: Completed 500 Internal Server Error in 727ms
2015-06-05T12:22:20.007724+00:00 app[web.1]:
2015-06-05T12:22:20.007729+00:00 app[web.1]:   app/controllers/shops_controller.rb:38:in `block in update'
2015-06-05T12:22:20.007731+00:00 app[web.1]:
2015-06-05T12:22:20.007727+00:00 app[web.1]: URI::InvalidURIError (bad URI(is not URI?): ://s3.amazonaws.com:):
2015-06-05T12:22:20.007730+00:00 app[web.1]:   app/controllers/shops_controller.rb:37:in `update'
2015-06-05T12:22:20.007733+00:00 app[web.1]:
2015-06-05T12:22:20.011815+00:00 heroku[router]: at=info method=POST path="/shops/1" host=mysite-staging.herokuapp.com request_id=9e23541f-96d2-430c-95a7-5e77dbc2f69c fwd="80.30.158.93" dyno=web.1 connect=3ms service=20983ms status=500 bytes=1543

0 个答案:

没有答案