Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] encourting "Path problem" when trying to save a uploaded file , but work well in tomcat---Jetty 9.2.9.v20150224

Tomcat is not obeying the servlet spec.

The org.springframework.web.multipart.MultipartFile javadoc for the
transferTo(File) method says:

  "Note: when using Servlet 3.0 multipart support you need to
configure the location relative to which files will be copied as
explained in Part.write(java.lang.String)."

The javax.servlet.http.Part javadoc for the write(String) method says:

   "fileName - the name of the file to which the stream will be
written. The file is created relative to the location as specified in
the MultipartConfig"

In other words, you can't just write it anywhere on disk, it has to be
a location relative to the location configured in MultipartConfig,
which by default is the webapp's tmp directory.

Jan

On 17 May 2015 at 02:55, 五星上酱 <50712369@xxxxxx> wrote:
> Hi ,every body
>    example code like this:
>
>
>   // mulitpartFiletype is org.springframework.web.multipart.MultipartFile
>    mulitpartFile.transferTo(new File("G:\\somedir/somefile"));
>
>
>    this code work well with Tomcat
>
>    but ,when with Jetty , raises java.io.FileNotFoundException:
> D:\projects\project1\target\tmp\G:\ somedir/somefile
>
>    the problem is file path is prefixed with the tempolary path
>    Why Jetty will prefix an absolute path with the tempolary path? Can I
> avoid it?
>
>    hoping someone can help me.thanks
>
>
>
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-users



-- 
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
'Expert assistance from the creators of Jetty and CometD'


Back to the top