问题
)
I have some cloudinary's photos and I would like to make a seed (in my rails app). I'm using Carrierwave.
In my seed, I try to put the cloudinary's url image :
Course.create! ({
photo: "fismpnq3zma80dc2ovjt.jpg"
)}
But it's don't work. What can I do ?
If I ask by console :
pry(main)> c = Course.first
....
pry(main)> c.photo
@cache_id=nil,
@file=nil,
@filename=nil,
....
@model=#<Way:0x00007f80e7a3a9c0
photo:nil,
....
@mounted_as=:photo,
@versions=nil>
回答1:
In order to use the create
method, the parameters need to be verified (by signature) before the SDK will save them.
For example:
resource_type = "image"
type = "upload"
version = 1234567890
public_id = "fismpnq3zma80dc2ovjt"
format = "jpg"
signature = Cloudinary::Utils.api_sign_request({:public_id=>public_id,
:version=>version}, Cloudinary.config.api_secret)
photo = "#{resource_type}/#{type}/v#{version}/#{public_id}.#{format}##
{signature}"
Course.create!({ photo: photo )}
Please let me know if it works for you.
--Yakir
来源:https://stackoverflow.com/questions/51163036/seed-cloudinary-photos-for-rails-app