[ 
https://issues.apache.org/jira/browse/WICKET-6425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Grigorov resolved WICKET-6425.
-------------------------------------
    Resolution: Not A Problem

This is by Servlet 3 specification.

The javadoc of javax.servlet.http.Part says:
{code}
 /**
     * A convenience method to write this uploaded item to disk.
     * 
     * <p>This method is not guaranteed to succeed if called more than once for
     * the same part. This allows a particular implementation to use, for
     * example, file renaming, where possible, rather than copying all of the
     * underlying data, thus gaining a significant performance benefit.
     *
     * @param 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
     *
     * @throws IOException if an error occurs.
     */
    public void write(String fileName) throws IOException;
{code}.

"The file is created relative to the location as specified in the 
MultipartConfig".

Servlet 3 file uploads have many restrictions compared to commons-fileupload :-/

> ServletPartFileItem saves file to wrong location
> ------------------------------------------------
>
>                 Key: WICKET-6425
>                 URL: https://issues.apache.org/jira/browse/WICKET-6425
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 7.8.0
>            Reporter: Richard Eckart de Castilho
>
> ServletPartFileItem.write() receives an absolute path to a temporary location 
> from FileUpload.writeToTempFile(). However, it discards the full path and 
> passes on only the file name itself.
> {noformat}
>       @Override
>       public void write(File file) throws Exception
>       {
>               part.write(file.getName());
>       }
> {noformat}
> So "file" here is an absolute location to a temporary file in the temp folder.
> Next, Tomcat's ApplicationPart.write() turns `file.getName()` back into a 
> file which is now relative to the current working directory. 
> Thus, the downloaded file never ends up in the location requested by 
> FileUpload.writeToTempFile().
> Relevant stack
> {noformat}
> Daemon Thread [http-nio-8080-exec-5] (Suspended)      
>       owns: NioEndpoint$NioSocketWrapper  (id=137)    
>       DiskFileItem.write(File) line: 388      
>       ApplicationPart.write(String) line: 120 
>       ServletPartFileItem.write(File) line: 140       
>       FileUpload.writeTo(File) line: 234      
>       FileUpload.writeToTempFile() line: 254  
> ...
> {noformat}
> Using Tomcat 8.5.16, Wicket 7.8.0



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to