Skizzo
Skizzo

Reputation: 2983

File uploaded in postgres db

I'm new of vaadin and I'm developing my first application with spring and vaadin.

Now I'm trying to save an image inside my database. I followed the description of upload component on vaadin-book (Upload Component)

What do I have to change if I want to store it in the database? Can you give me an example?

Upvotes: 0

Views: 1871

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 324891

The upload component writes the received data to an java.io.OutputStream so you have plenty of freedom in how you can process the upload content

If you want to store it as a large object, you can write directly as the stream comes in. See large object support.

If you want to store it as bytea in a row, you must accumulate it in memory then pass it to a parameterized query with setObject(parameterIndex, myDataBuffer, Types.BLOB) . This will consume several times the object's size in memory, so bytea is really only well suited to smaller data.

Upvotes: 1

Related Questions