Images from Disk to Db?

Hi Folks, just some general guidance would be useful.

We have a set of links to Images saved on disk and we’d like to use those links to copy the images to a db column for the related records (moving from our old system of linking to docs and images to the new integrated set-up). Not really sure of the best approach, I assume we need to do this:

  1. Locate the image file
  2. Convert it to byte
  3. Create a new record in the images table
  4. Save the byte array to the images table in a media column

Q. Is this the correct approach?
Q. How do we convert the file from an image file on disk to byte (getBytes()? how is that formatted?) ?

The wiki says this

getBytes
bytegetBytes()
Returns
byte

Appreciate feedback as always.

yes you can use JSFile.getBytes() to get the byte from a file on disk (what ever file it is)
That can then the stored to a blob on a record in the db.

You could also use the streaming features of the fileplugin to stream the file to the server and only store the file name in the record.

jcompagner:
yes you can use JSFile.getBytes() to get the byte from a file on disk (what ever file it is)
That can then the stored to a blob on a record in the db.

You could also use the streaming features of the fileplugin to stream the file to the server and only store the file name in the record.

Thanks for that Johan

Do I need to do anything with the file when I show the image in a form media field (I’ve only used the Load Image Data so far to test the display form and that works fine from the media DP)?

no, bytes are bytes.

Cheers thanks Johan