Regarding the FileUpload project, how to get charset info from FileItemStream?

View: New views
2 Messages — Rating Filter:   Alert me  

Regarding the FileUpload project, how to get charset info from FileItemStream?

by Jason Wang-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

I just started using the fileupload API to write a REST API a couple of
days ago. Now I run into a problem: I don't know how to get the charset
from uploaded files when using the streaming API.

For example, I can upload files using httpclient library via a  
multipart post:

        String url = "https://localhost:8040/api/1/sms/out";
        PostMethod post = new PostMethod(url);

        File smilFile = new File("main.smil");

        Part smil = new FilePart(smilFile.getName(),
smilFile,"application/smil","UTF-8"); // the last paramater takes in the
charset.

I noticed that there is a getCharset() method in class DiskFileItem.
Unfortunately, when using the stream api, I should be dealing with the
FileItemStream objects only. Could anyone give any help on this?

Thanks a lot.

Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Regarding the FileUpload project, how to get charset info from FileItemStream?

by Jason Wang-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jason Wang wrote:

> Hi there,
>
> I just started using the fileupload API to write a REST API a couple
> of days ago. Now I run into a problem: I don't know how to get the
> charset from uploaded files when using the streaming API.
>
> For example, I can upload files using httpclient library via a  
> multipart post:
>
>        String url = "https://localhost:8040/api/1/sms/out";
>        PostMethod post = new PostMethod(url);
>
>        File smilFile = new File("main.smil");
>
>        Part smil = new FilePart(smilFile.getName(),
> smilFile,"application/smil","UTF-8"); // the last paramater takes in
> the charset.
>
> I noticed that there is a getCharset() method in class DiskFileItem.
> Unfortunately, when using the stream api, I should be dealing with the
> FileItemStream objects only. Could anyone give any help on this?
>
> Thanks a lot.
>
> Jason
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
Problem solved. Found the getHeaders method FileItemStream inherits from
an interface. Sorry to spam you  all.  I  should have been figured it
out before dumping an email to the mail list.

Cheers,

Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...

LightInTheBox - Buy quality products at wholesale price