[Rails] Uploading data uri to Cloudinary

8 views
Skip to first unread message

Fernando Aureliano

unread,
Aug 12, 2016, 9:47:53 AM8/12/16
to Ruby on Rails: Talk
Hi!

I'm using Heroku and I have the Cloudinary running with my project. The upload works fine, but when I try to upload some Data Uri to Cloudnary its not work. I saw the documentation and I know I have to use the function. I'm using carrierwave-data-uri to generate images from data-uri, It works locally, but when I change the code to integra with Cloudinary I get empty images on cloud

I know I have to use the function Cloudinary::Uploader.upload(photo) but it is not clear to me how can I integrate it to my function:

  def upload_image
    photo = params[:picture][:photo]  
    @picture = Picture.new(picture_params)
    @picture.photo_data_mimetype = 'image/jpeg'
    @picture.user_id = current_user.id 
    @picture.photo_data_uri = photo
    @picture.save
  end

who receives the data to image from javascript. If I just do Cloudinary::Uploader.upload(photo), the image is not associated with the record in my database

Thanks!



Reply all
Reply to author
Forward
0 new messages