How to save a Canvas via Paperclip

点点圈 提交于 2019-12-06 05:14:45

The first approach should be the good one. The string created put the mime type at start, and paperclip can handle base64 string.

Example in one of our projects (working well)

 #in our coffeescript (own ajax method, no jquery, but same behavior)
 ajax("images",
  method: "post",
  data: {image: @state.src}
 ).then((result) =>
   console.log "yey"
 )

 #In the image_controller, to add an uploaded picture
 def create
   current_user.photos.new picture: params[:image]
 end

Our paperclip version is 4.3.3. We use it with Html5 File API, not canvas, but the output (base64) is exactly same format than the Canvas#toDataUrl, as long as we can display a preview in a src attribute of an image.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!