aspose file tools*
The moose likes Java in General and the fly likes how to convert blob to multipartfile in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to convert blob to multipartfile in java" Watch "how to convert blob to multipartfile in java" New topic
Author

how to convert blob to multipartfile in java

Sally william
Greenhorn

Joined: Mar 03, 2012
Posts: 15
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

Joined: Aug 10, 2012
Posts: 4
hi thanks for your information...........
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
Consider Paul's rocket mass heater.
 
subject: how to convert blob to multipartfile in java