Skip to main content

[JIRA] Commented: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

  • From: "beamerblvd (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [JIRA] Commented: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part
  • Date: Wed, 20 Feb 2013 15:36:53 +0000 (GMT+00:00)
  • Auto-submitted: auto-generated


    [ 
http://java.net/jira/browse/SERVLET_SPEC-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=356616#action_356616
 ] 

beamerblvd commented on SERVLET_SPEC-57:
----------------------------------------

By the way, Mark, if this gets accepted for 3.1 I'll implement it in Tomcat. 
Should just be a matter of adding the method to the interface and then 
renaming and @Overriding ApplicationPart#getFilename().

> Add getFileName() method to javax.servlet.http.Part
> ---------------------------------------------------
>
>                 Key: SERVLET_SPEC-57
>                 URL: http://java.net/jira/browse/SERVLET_SPEC-57
>             Project: servlet-spec
>          Issue Type: Improvement
>         Environment: All
>            Reporter: beamerblvd
>   Original Estimate: 2 hours
>  Remaining Estimate: 2 hours
>
> The {{javax.servlet.http.Part}} interface lacks a method for retrieving the 
> file name of a part. Most request parts have file names, typically provided 
> by the client's browser as the name of the file on the client's file system 
> when the file is uploaded through the form submission. Currently, consumers 
> of {{Part}} must create their own method to extract the file name:
> {code}public static String getFileName(Part filePart)
> {
>     String header = filePart.getHeader("content-disposition");
>     for(String headerPart : header.split(";"))
>     {
>         if(headerPart.trim().startsWith("filename"))
>         {
>             return headerPart.substring(headerPart.indexOf('=') + 1).trim()
>                              .replace("\"", "");
>         }
>     }
>     return null;
> }{code}
> Tomcat, as an example, already has a method to extract the file name in its 
> {{Part}} implementation, but since it is not exposed via the public 
> {{Part}} interface developers cannot use it without limiting the 
> portability of their applications. It's possible other containers already 
> do something similar.
> The suggested {{getFileName()}} method should:
> - Locate the {{Content-Disposition}} header from the {{Part}}. If no such 
> header exists, return {{null}}.
> - Extract the {{filename}} attribute from the {{Content-Disposition}} 
> header and return its value trimmed.
> - If no {{filename}} attribute exists or the {{filename}} attribute value 
> is {{null}}, return {{null}}.
> - Not throw any exceptions.
> Estimate 5 minutes to add the method to the interface and < 2 hours to add 
> relevant documentation regarding the method to the spec.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[JIRA] Created: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

beamerblvd (JIRA) 02/18/2013

[JIRA] Commented: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

beamerblvd (JIRA) 02/18/2013

[JIRA] Issue Comment Edited: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

beamerblvd (JIRA) 02/18/2013

[JIRA] Commented: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

carojkov (JIRA) 02/18/2013

[JIRA] Commented: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

beamerblvd (JIRA) 02/18/2013

[JIRA] Commented: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

markt_asf (JIRA) 02/18/2013

[JIRA] Commented: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

beamerblvd (JIRA) 02/20/2013

[JIRA] Issue Comment Edited: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

beamerblvd (JIRA) 02/20/2013

[JIRA] Assigned: (SERVLET_SPEC-57) Add getFileName() method to javax.servlet.http.Part

Shing Wai Chan (JIRA) 02/28/2013
 
 
Close
loading
Please Confirm
Close