【发布时间】:2020-03-15 12:36:29
【问题描述】:
ActiveStorage image_url 帮助器生成一个指向 Rails Web 服务器上图像的 URL。当 Web 服务器上收到该请求时,它会被重定向到 Cloudinary 上的 URL 以请求图像。 ActiveStorage 使用 https 协议生成图像 URL,但 Rails Web 服务器使用 http(无 ssl)协议生成到 Cloudinary 的图像 URL。我无法确定原因。
请求的日志:
Started GET "/rails/active_storage/blobs/really_long_hash/user-2.png"
Processing by ActiveStorage::BlobsController#show as JPEG
Parameters: {"signed_id"=>"really_long_hash", "filename"=>"nsi-site-bg"}
ActiveStorage::Blob Load (0.8ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 48], ["LIMIT", 1]]
Cloudinary Storage (4.3ms) Generated URL for file at key: cloudinary_file_name (http://res-4.cloudinary.com/hcfhlrdjg/image/upload/cloudinary_file_name.jpg)
Redirected to http://res-4.cloudinary.com/hcfhlrdjg/image/upload/cloudinary_file_name.jpg
Completed 302 Found in 48ms (ActiveRecord: 13.8ms)
cloudinary.yml
development:
cloud_name: <%= ENV['CLOUDINARY_CLOUD_NAME'] %>
api_key: <%= ENV['CLOUDINARY_API_KEY'] %>
api_secret: <%= ENV['CLOUDINARY_API_SECRET'] %>
secure: true
cdn_subdomain: true
production:
cloud_name: <%= ENV['CLOUDINARY_CLOUD_NAME'] %>
api_key: <%= ENV['CLOUDINARY_API_KEY'] %>
api_secret: <%= ENV['CLOUDINARY_API_SECRET'] %>
secure: true
cdn_subdomain: true
test:
cloud_name: <%= ENV['CLOUDINARY_CLOUD_NAME'] %>
api_key: <%= ENV['CLOUDINARY_API_KEY'] %>
api_secret: <%= ENV['CLOUDINARY_API_SECRET'] %>
secure: true
cdn_subdomain: true
我刚刚将 cloudinary gem 更新到 1.13.0 并没有看到任何变化。如果您还需要什么,请告诉我。
【问题讨论】:
标签: ruby-on-rails https cloudinary imageurl