ruby-on-rails - 使用carrierwave从Rails将图像上传为私有云
问题描述
我正在开发一个 Rails 网站,该网站需要在 Cloudinary 上将图像上传为私有。现在它在 Cloudinary 上公开上传图片。
我可以使用以下命令在 Cloudinary 上手动将文件上传为私有文件:
Cloudinary::Uploader.upload("Photo No. 11.jpeg", :type => :private)
图像变得私密且无法访问。
有没有办法用 Carrierwave 做到这一点?
解决方案
你应该在你的上传器中做这样的事情
class PictureUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
make_private # This will make sure you're images are uploaded as private
eager
version :medium do
process :resize_to_fill => [164, 164, 'North']
process :convert => 'jpg'
cloudinary_transformation :quality => 80
end
end
推荐阅读
- android - Android - 将数据传递给另一个活动
- python - 如何反复“收听”图像以显示在目录中并显示几秒钟?
- c# - 如何协调 .net 后端和 asp.net Web 应用程序之间的文件共享
- email - 如何在电子邮件模板 prestashop 中添加产品名称?
- php - Laravel PDO::exec() 期望参数 1 是字符串,给定对象
- c# - 我想计算 C# 中字符串中“e”字符的数量
- javascript - 在拾取箭头键时,我的 Javascript 程序除了 console.log() 不会执行任何操作
- java - TreeTableView 行动态样式格式化失败
- r - 将不均匀列表转换为 data.frame
- amazon-web-services - 重启后删除Jenkins配置