ruby on rails - Save a blob object with paperclip -


i have data uri want upload server , store paperclip image attachment. used info on link convert data uri blob , used formdata upload server. coffeescript file looks this

dataurltoblob = (dataurl) ->   binary = atob dataurl.split(',')[1]   array = []   = 0   while < binary.length     array.push binary.charcodeat(i)     i++   return new blob [new uint8array(array)], {type: 'image/png'}  file = dataurltoblob(imagesrc) fd = new formdata() fd.append "image", file $.ajax({    url: "/posts",    type: "post",    data: fd,    processdata: false,    contenttype: false, }); 

and create action in controller

image = params[:image] name = securerandom.hex + "png" file.open("#{rails.root}/public/uploads/#{name}", 'wb') |f|   f.write(image.read) end 

this works storing image on server. how integrate paperclip, i.e. generate thumbnails, urls these images? in advance.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -