We've used the method mentioned by Ruchira in Carbon. Have a look at the
following class in Carbon

org.wso2.carbon.utils.FileItemDataSource.

Sameera

On Thu, Oct 21, 2010 at 10:18 AM, Ruchira Wageesha <[email protected]> wrote:

> If you want, you can create a DataHandler using a custom implementation of
> javax.activation.DataSource. i.e.
>
> public class CustomDataSource implements DataSource {
>
>     private FileItem fileItem;
>
>     public CustomDataSource(FileItem fileItem) {
>         this.fileItem = fileItem;
>     }
>     public InputStream getInputStream() throws IOException {
>         return fileItem.getInputStream();
>     }
>
>     public OutputStream getOutputStream() throws IOException {
>         return fileItem.getOutputStream();
>     }
>
>     public String getContentType() {
>         return fileItem.getContentType();
>     }
>
>     public String getName() {
>         return fileItem.getName();
>     }
> }
>
> and you can create DataHandler using
>
> DataHandler handler = new DataHandler(new CustomDataSource(new
> FileItem(......)));
>
> but there may be a better method.
>
> regards,
> Ruchira
>
> On Thu, Oct 21, 2010 at 9:46 AM, Shariq <[email protected]> wrote:
>
>> Hi all,
>>
>> I want to know if $Subject is possible. My requirement is to retrieve a
>> .car File in the registry and upload it as a CarbonApp
>> using CarbonAppUploader service defined in application-mgt component. The
>> method "resource.getContentStream()" method returns an InputStream. I need
>> to convert this InputStream to a DataHandler since the  CarbonAppUploader
>> service requires a DataHandler as an argument. How can I get this done?
>>
>> Also I noticed a method "resource.getContent()" which returns a Object. Is
>> there a possibility of using this method in order to fulfill my requirement?
>>
>> Thanks,
>> Shariq.
>>
>>
>>
>> _______________________________________________
>> Carbon-dev mailing list
>> [email protected]
>> https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>
>>
>
>
> --
> Ruchira Wageesha
> Software Engineer - WSO2 Inc. www.wso2.com
>
> Email: [email protected] Blog: [email protected]
> Mobile: +94771083016, +94714439028
>
> Lean . Enterprise . Middleware
>
> _______________________________________________
> Carbon-dev mailing list
> [email protected]
> https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>
>


-- 
Sameera Jayasoma
Technical Lead and Product Manager, WSO2 Carbon

WSO2, Inc. (http://wso2.com)
email: [email protected]
blog: http://tech.jayasoma.org

Lean . Enterprise . Middleware
_______________________________________________
Carbon-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev

Reply via email to