我試圖將圖片上傳到谷歌雲存儲從我的軌道4.2應用程序使用載波寶石。每當我去上傳圖片時,我都會收到錯誤hostname "project-name.appspot.com.storage.googleapis.com" does not match the server certificate (OpenSSL::SSL::SSLError)
。hostname「project-name.appspot.com.storage.googleapis.com」與服務器證書(OpenSSL :: SSL :: SSLError)不匹配 - 使用霧和carriewave
我無法看到我需要從這裏做什麼。
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 docs,this post和this video來獲得我現在擁有的東西。我錯過了什麼導致了這個錯誤?
你需要告訴的寶石,SSL是活躍的。 – 13aal
這也可能會幫助你https://github.com/carrierwaveuploader/carrierwave/issues/667 – 13aal
@ 13aal我創建了另一個名稱中沒有點的桶並且工作正常。發佈這個答案,生病給你。謝謝 – Rob