• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to convert blob to multipartfile in java

 
Sally william
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've stored the image to db as blob type. During uploading the image will be passed to DTO that has MultipartFile:

type to carry the image. My entity look like:

Then i convert the image dto attribute to blob in service side :

I need to display that image on my JSP page, and i need to set back all my entity attributes to DTO attributes.

Something like this:

I know i cannot simply set it to the DTO. Tried to google and find in forums..but could'nt find the correct way of doing it yet..

Please help..
 
priya uma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi thanks for your information...........
 
Winston Gutkowski
Bartender
Pie
Posts: 10509
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sally william wrote:...Then i convert the image dto attribute to blob in service side:I need to display that image on my JSP page, and i need to set back all my entity attributes to DTO attributes...

I'm afraid I'm no expert on this stuff, but I don't see the setPicture() method that you appear to be trying to call (I do see setPictureFileName() though).

However, one tip that might help you out: Split your statements up into single actions.

That statement of yours above is doing at least 4 things that I can see (and maybe more under the hood), and it makes it very difficult to determine what's going wrong if you run into problems.

If you were to write:you would be accomplishing exactly the same thing (I think ), and you could then add debugging statements in between each stage to check that what you think is happening is in fact happening; and I think my first one would be to display picBytes.length.

In addition, it also makes it much easier for the next poor soul who has to maintain that program to understand what it's trying to do.

It's a really good mantra to learn - Write Dumb Code (←click).

HIH

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic