users@jersey.java.net

[Jersey] Re: Jersey truncating the slashes from the uploaded file name

From: ManiKanta G <go4mani_at_gmail.com>
Date: Thu, 3 Feb 2011 17:21:42 +0530

Hi,

Below is the Fiddler's log for the upload request:

POST http://localhost:9998/ex HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, application/xaml+xml,
application/x-ms-xbap, application/x-ms-application, */*
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;
.NET CLR 2.0.50727; .NET4.0C; .NET4.0E)
Content-Type: multipart/form-data;
boundary=---------------------------7db3c8365097e
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Content-Length: 522
Host: localhost:9998
Pragma: no-cache

-----------------------------7db3c8365097e
Content-Disposition: form-data; name="file"; filename="C:\Documents and
Settings\User1\Desktop\TODO.txt"
Content-Type: text/plain

<File content goes here...>
-----------------------------7db3c8365097e--


But printing the disposition.getFileName() in resource is giving:

C:Documents and SettingsUser1DesktopTODO.txt


I've tested in both IE8 & IE7 and the same behavior is observed.

Thanks,
ManiKanta G
twitter.com/ManiKantaG


On Wed, Feb 2, 2011 at 2:50 PM, Paul Sandoz <Paul.Sandoz_at_oracle.com> wrote:

> Hi,
>
> I am not precisely sure what "file path" you are referring to, is it the
> value of the file name obtained from the content disposition?
>
> Could you send an example e.g. from logging or from snooping on the HTTP
> port?
>
> Paul.
>
> On Feb 2, 2011, at 10:03 AM, ManiKanta G wrote:
>
>
> Hi,
>
> While uploading files from IE, Jersey resource is getting the file path
> without any slashes (as IE' behavior for file uploads is different from the
> other browsers in that it sends the complete file path of the user' system
> as the file name). Is there any way to stop this default behavior of
> Jersey of truncating the slashes from path.
>
> The code I m using is no different from the one the documentation suggest:
>
> @Path("upload")
> @POST
> @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
> @Consumes(MediaType.MULTIPART_FORM_DATA)
> public Response uploadFile(
> @FormDataParam("file") FormDataContentDisposition disposition ,
> @FormDataParam("file") FormDataBodyPart part) {
> String fileName = disposition.getFileName();
>
> // some code to save the file with the user uploaded file name
> }
>
>
>
> Or in general, is there any place I can hook some code in place or before
> the actual parameters were set in the resource class. I m
> actually interested to know where all the resource class annotation
> processing will be done.
>
> Thanks,
> ManiKanta G
> twitter.com/ManiKantaG
>
>
>