jsr340-experts@servlet-spec.java.net

[jsr340-experts] Re: [servlet-spec users] part.write() return value

From: Ted Goddard <ted.goddard_at_icesoft.com>
Date: Mon, 18 Jul 2011 09:37:08 -0600

An absolute path doesn't entirely solve the problem -- the application might
want to make use of the MultipartConfig-specified location at deployment time,
but might also want to know where the file was written.

The option for an absolute path is useful, but should be covered by the spec. Currently
the JavaDoc 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

Which could be interpreted as always prepend the "location" no matter what the
structure of the fileName.

Ted.

On 2011-07-16, at 7:22 AM, Mark Thomas wrote:

> On 15/07/2011 21:46, Ted Goddard wrote:
>>
>> On javax.servlet.http.Part we currently have the method
>>
>> void write(java.lang.String fileName)
>>
>> but it's not easy for application code to get to the written file
>> because MultipartConfig.location can be modified at deployment time.
>
> Tomcat allows fileName to be absolute. Only if it is relative is
> MultipartConfig.location used. Does that solve the problem?
>
> Mark
>
>> Perhaps the easiest thing would be to have the written File returned:
>>
>> java.io.File write(java.lang.String fileName)
>>
>> or add Part.getFile() (which could return null if the file has not been
>> written -- the interface does seem to allow multipart uploads that are not
>> stored immediately on the file system; do any implementations work this way?)
>
>
>>
>> Cheers,
>> Ted.
>>
>>
>
>
>