Hi all!
I am converting a Rails app to MRI from JRuby and I am looking for a way to store large binary data into a bytea column without having to hold it all in memory.
With JRuby I use the JDBC raw connection and set up streaming:
```ruby
class Image < ActiveRecord::Base
def store_file(filename)
conn = self.class.connection.raw_connection.connection
is = java.io.FileInputStream.new(java.io.File.new(filename))
st = conn.prepareStatement('UPDATE images SET content_data = ? WHERE id = ?')
st.java_send(:setBinaryStream, [Java::int, java.io.InputStream, Java::int], 1, is, is.available)
st.setInt(2, id)
st.executeUpdate
st.close
end
end
```
How should I do this with pg? Any response is welcome :)
--
Uwe Kubosch