Package org.eclipse.jetty.http
Class MultiPartFormInputStream.MultiPart
- java.lang.Object
-
- org.eclipse.jetty.http.MultiPartFormInputStream.MultiPart
-
- All Implemented Interfaces:
Part
- Enclosing class:
- MultiPartFormInputStream
public class MultiPartFormInputStream.MultiPart extends java.lang.Object implements Part
-
-
Constructor Summary
Constructors Constructor Description MultiPart(java.lang.String name, java.lang.String filename)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Only remove tmp files.voiddelete()Remove the file, whether or not Part.write() was called on it (ie no longer temporary)byte[]getBytes()java.lang.StringgetContentDispositionFilename()Get the filename from the content-disposition.java.lang.StringgetContentType()Obtain the content type passed by the browser ornullif not defined.java.io.FilegetFile()Get the filejava.lang.StringgetHeader(java.lang.String name)Obtains the value of the specified part header as a String.java.util.Collection<java.lang.String>getHeaderNames()Returns a Collection of all the header names provided for this part.java.util.Collection<java.lang.String>getHeaders(java.lang.String name)Obtain all the values of the specified part header.java.io.InputStreamgetInputStream()Obtain anInputStreamthat can be used to retrieve the contents of the file.java.lang.StringgetName()Obtain the name of the field in the multipart form corresponding to this part.longgetSize()Obtain the size of this part.java.lang.StringgetSubmittedFileName()If this part represents an uploaded file, gets the file name submitted in the upload.java.lang.StringtoString()voidwrite(java.lang.String fileName)A convenience method to write an uploaded part to disk.
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getContentType
public java.lang.String getContentType()
Description copied from interface:PartObtain the content type passed by the browser ornullif not defined.- Specified by:
getContentTypein interfacePart
-
getHeader
public java.lang.String getHeader(java.lang.String name)
Description copied from interface:PartObtains the value of the specified part header as a String. If there are multiple headers with the same name, this method returns the first header in the part. The header name is case insensitive.
-
getHeaderNames
public java.util.Collection<java.lang.String> getHeaderNames()
Description copied from interface:PartReturns a Collection of all the header names provided for this part.- Specified by:
getHeaderNamesin interfacePart
-
getHeaders
public java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
Description copied from interface:PartObtain all the values of the specified part header. If the part did not include any headers of the specified name, this method returns an empty Collection. The header name is case insensitive.- Specified by:
getHeadersin interfacePart
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionDescription copied from interface:PartObtain anInputStreamthat can be used to retrieve the contents of the file.- Specified by:
getInputStreamin interfacePart- Throws:
java.io.IOException
-
getSubmittedFileName
public java.lang.String getSubmittedFileName()
Description copied from interface:PartIf this part represents an uploaded file, gets the file name submitted in the upload. Returnsnullif no file name is available or if this part is not a file upload.- Specified by:
getSubmittedFileNamein interfacePart- Returns:
- the submitted file name or
null.
-
getBytes
public byte[] getBytes()
-
getName
public java.lang.String getName()
Description copied from interface:PartObtain the name of the field in the multipart form corresponding to this part.
-
getSize
public long getSize()
Description copied from interface:PartObtain the size of this part.
-
write
public void write(java.lang.String fileName) throws java.io.IOExceptionDescription copied from interface:PartA convenience method to write an uploaded part to disk. The client code is not concerned with whether or not the part is stored in memory, or on disk in a temporary location. They just want to write the uploaded part to a file. 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.- Specified by:
writein interfacePart- Parameters:
fileName- The location into which the uploaded part should be stored. Relative locations are relative toMultipartConfigElement.getLocation()- Throws:
java.io.IOException
-
delete
public void delete() throws java.io.IOExceptionRemove the file, whether or not Part.write() was called on it (ie no longer temporary)
-
cleanUp
public void cleanUp() throws java.io.IOExceptionOnly remove tmp files.- Throws:
java.io.IOException- if unable to delete the file
-
getFile
public java.io.File getFile()
Get the file- Returns:
- the file, if any, the data has been written to.
-
getContentDispositionFilename
public java.lang.String getContentDispositionFilename()
Get the filename from the content-disposition.- Returns:
- null or the filename
-
-