主机名" project-name.appspot.com.storage.googleapis.com"与服务器证书(OpenSSL :: SSL :: SSLError)不匹配 - 使用雾和carriewave

时间:2016-05-25 01:46:38

标签: ruby-on-rails ruby google-cloud-storage carrierwave fog

我尝试使用carrierwave gem从我的rails 4.2应用程序实现图像上传到谷歌云存储。每当我上传图片时,都会收到错误hostname "project-name.appspot.com.storage.googleapis.com" does not match the server certificate (OpenSSL::SSL::SSLError)

我无法从这里看到我需要做什么。

carrierwave.rb文件

CarrierWave.configure do |config|
  config.fog_credentials = {
    provider:                         'Google',
    google_storage_access_key_id:     'key',
    google_storage_secret_access_key: 'secret key'
  }
  config.fog_directory = 'project-name.appspot.com'
end

上传/ check_item_value_image_uploader.rb

class CheckItemValueImageUploader < CarrierWave::Uploader::Base

  # Include RMagick or MiniMagick support:
  # include CarrierWave::RMagick
  # include CarrierWave::MiniMagick

  # 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
    "check-item-value-images/#{model.id}"
  end

  # Add a white list of extensions which are allowed to be uploaded.
  # For images you might use something like this:
   def extension_white_list
     %w(jpg jpeg gif png)
   end

end

相关宝石

gem 'gcloud'
gem "fog"
gem 'google-api-client', '~> 0.8.6'
gem "mime-types"

check_category_item_value模型

mount_uploader :value, CheckItemValueImageUploader

check_category_item_value更新方法

if @check_category_item_value.save 
   flash[:success] = "Successfully updated"
   redirect_to category_items_edit_path(@guide, @category, @category_item)
else
   render 'category_items/edit'
end

编辑表格

 <%= form_for(@check_category_item_value) do |f| %>
   <%= f.file_field :value, :value => item_key.value, accept: "image/jpeg, image/jpg, image/gif, image/png" %>
   <%= f.submit "Submit" %><hr>
 <% end %>

在我为图像上传实现了carrierwave之前,表单工作正常(只保存文件名字符串而不上传图像)。现在我已经尝试为图像上传实现载波,我得到了上面的错误。

我使用谷歌云平台的carrierwave docsthis postthis video来获取我现在拥有的内容。我错过了什么导致了这个错误?

1 个答案:

答案 0 :(得分:0)

问题是在使用carrierwave时,您的存储桶中有点(.)。

创建另一个没有圆点的桶,它会起作用。

这里有一些examples,似乎你不是唯一拥有problem

的人