Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

convert UploadedFile to DataHandler

user5636757Jun 14 2013 — edited Jul 3 2013

hi,

i have to provide an option for user to upload a file on website.

i am using af:inputFile and able to get file in UploadedFile object.

now i've to transfer this file to a server and that server's API is expecting javax.activation.DataHandler object.

does anyone know how to convert UploadedFile to DataHandler?

DataHandler has constructor which accepts URL - but i don't know how to convert UploadedFile to URL (i know java.io.File can be converted to java.net.URL).

It also accepts DataSource interface but I don't know how to create FileDataSource from UploadedFile?

It has another constructor which accepts data (Object) and MIME type - again how to convert UploadedFile to data Object?

I don't want to write file to a temporary location and read it in File object.

any help?

thanks.

This post has been answered by dvohra21 on Jun 26 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 31 2013
Added on Jun 14 2013
7 comments
1,347 views