Interface Part
-
@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface Part
Part interface inspired from HTTP Servlet 5.0.- Since:
- 26
*********************************
EXPERIMENTAL - Subject to change
********************************
Please note that this API is not marked as final and it can change in one of the next versions of the application. If you have suggestions, comments about it, please let us know.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
delete()
Deletes the underlying storage for a file item, including deleting any associated temporary disk file.java.lang.String
getContentType()
Gets the content type of this part.java.lang.String
getHeader(java.lang.String name)
Returns the value of the specified mime header as aString
.java.util.Collection<java.lang.String>
getHeaderNames()
Gets the header names of this Part.java.util.Collection<java.lang.String>
getHeaders(java.lang.String name)
Gets the values of the Part header with the given name.java.io.InputStream
getInputStream()
Gets the content of this part as an InputStreamjava.lang.String
getName()
Gets the name of this partlong
getSize()
Returns the size of this fille.java.lang.String
getSubmittedFileName()
Gets the file name specified by the clientvoid
write(java.lang.String fileName)
A convenience method to write this uploaded item to disk.
-
-
-
Method Detail
-
getInputStream
java.io.InputStream getInputStream() throws java.io.IOException
Gets the content of this part as an InputStream- Returns:
- The content of this part as an InputStream
- Throws:
java.io.IOException
- If an error occurs in retrieving the content as an InputStream
-
getContentType
java.lang.String getContentType()
Gets the content type of this part.- Returns:
- The content type of this part.
-
getName
java.lang.String getName()
Gets the name of this part- Returns:
- The name of this part as a String
-
getSubmittedFileName
java.lang.String getSubmittedFileName()
Gets the file name specified by the client- Returns:
- the submitted file name
-
getSize
long getSize()
Returns the size of this fille.- Returns:
- a
long
specifying the size of this part, in bytes.
-
write
void write(java.lang.String fileName) throws java.io.IOException
A convenience method to write this uploaded item to disk.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.
- Parameters:
fileName
- The location into which the uploaded part should be stored. Relative paths are relative toMultipartConfigElement#getLocation()
. Absolute paths are used as provided. Note: that this is a system dependent string and URI notation may not be acceptable on all systems. For portability, this string should be generated with the File or Path APIs.- Throws:
java.io.IOException
- if an error occurs.
-
delete
void delete() throws java.io.IOException
Deletes the underlying storage for a file item, including deleting any associated temporary disk file.- Throws:
java.io.IOException
- if an error occurs.
-
getHeader
java.lang.String getHeader(java.lang.String name)
Returns the value of the specified mime header as aString
. If the Part did not include a header of the specified name, this method returnsnull
. If there are multiple headers with the same name, this method returns the first header in the part. The header name is case insensitive. You can use this method with any request header.- Parameters:
name
- aString
specifying the header name- Returns:
- a
String
containing the value of the requested header, ornull
if the part does not have a header of that name
-
getHeaders
java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
Gets the values of the Part header with the given name.Any changes to the returned
Collection
must not affect thisPart
.Part header names are case insensitive.
- Parameters:
name
- the header name whose values to return- Returns:
- a (possibly empty)
Collection
of the values of the header with the given name
-
getHeaderNames
java.util.Collection<java.lang.String> getHeaderNames()
Gets the header names of this Part.Some servlet containers do not allow servlets to access headers using this method, in which case this method returns
null
Any changes to the returned
Collection
must not affect thisPart
.- Returns:
- a (possibly empty)
Collection
of the header names of this Part
-
-