Bufferedimage for Bufferedimage or save Bufferedimage as a blob in the database

Asked

Viewed 30 times

0

hello, today I am working with facebook messenger and they send me the uploads images via url, this way ->

Bufferedimage image = Imageio.read(url);

and I need to save this in a column of my bank in blob format.

in a web chat I already had a service that sent me images in Multipartfile format and I could do the whole process of saving in the database.

already searched how to convert Bufferedimage to Multipartfile but so far no answers.

  • It speaks Durazzo Blz ? Try to see if it works !!! https://stackoverflow.com/questions/41163648/how-to-convert-bufferedimage-to-a-multipart-file-without-saving-file-to-disk Hug

  • It speaks Durazzo Blz ? Try to see if it works !!! https://stackoverflow.com/questions/41163648/how-to-convert-bufferedimage-to-a-multipart-file-without-saving-file-to-disk Hug

1 answer

0

The resolution of my problem turned out to be simple, Resolution->

  BufferedImage originalImage = ImageIO.read(url);

  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ImageIO.write(originalImage, "jpg", bos);
  byte[] data = bos.toByteArray();
  Blob blob = new SerialBlob(data);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.