Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
This sinatra app pulls binary data from postgres, once stored with attachment_fu
Ruby
branch: master
Failed to load latest commit information.
public
views
.rvmrc
Gemfile
Gemfile.lock
README.md
RMagick
viewimage.rb

README.md

This is a sinatra app that pulls some content from postgres. Notably it uses "PGconn.unescape_bytea" to compensate for Postgres's greedy escape_bytea which causes no end of pain.

! send_data is depricated

At first this is what I thought was the problem, but it was actually postgres driver in datamapper. So if you run into a problem of not being able to pull an image out of a postgres bytea then maybe this will help.

! Testing if you got image

If you have a byte aray in postgres holding your image data, here is how you can pull it out the hard way: Log into psql and do this:


    \copy (select encode(data, 'hex') from images where id=5) TO '/Users/yourname/Desktop/image.hex';   

That should make a hex version of the file. Then in terminal simply run:


    xxd -p -r image.hex > image.jpg
Something went wrong with that request. Please try again.