Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From your link to Canvas2Image above it looks to me like you are trying to handle Base64-encoded images (like <code>data:image/octet-stream;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wB</code>).</p> <p>Paperclip expects a <code>Tempfile</code> object, which is created behind the scenes for you when you upload an image. It is possible to fake a <code>Tempfile</code> by using a <code>StringIO</code> object and adding <code>content_type</code> and <code>original_filename</code> instance methods.</p> <p>I posted a gist with the code I used to accomplish this in one of my projects. <a href="https://gist.github.com/1012107" rel="nofollow">https://gist.github.com/1012107</a>.</p> <p>For you to do something similar you'd need to remove the beginning portion of the Canvas2Image URIs <code>data:image/octet-stream;base64,</code> and use the remaining Base64 code as the image_data. You'd need a way to provide or work around the content-type and filename.</p> <p>If you just want to use normal URLs like <code>http://example.com/image.jpg</code> then you have several available options.</p> <p>You could simply save the URL and use it as an image source on your pages. I know this isn't always an option, and you have no control over the availability of the image.</p> <p>Otherwise, there are several utilities such as net/http and curl that you could use to download the image. If you think you want to go this route then you might also consider downloading the images using delayed jobs or a similar background process. That way your UI doesn't hang if the image download is slow.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload