title: How to encode media in base64 given URL in Ruby
body: <p>I'm trying to upload an image to PingFM. Their <a href="https://code.google.com/p/pyngfm/" rel="noreferrer">documentation</a> says:</p>
  
  <pre><code>media – base64 encoded media data.
  </code></pre>
  
  <p>I can access this image via the URL. I tried (practically guessed) this:</p>
  
  <pre><code>ActiveSupport::Base64.encode64(open("http://image.com/img.jpg"))
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>TypeError: can't convert Tempfile into String
      from /usr/lib/ruby/1.8/base64.rb:97:in `pack'
      from /usr/lib/ruby/1.8/base64.rb:97:in `encode64'
      from (irb):19
      from :0
  </code></pre>