public class MultiPartInputStream.MultiPart extends Object implements Part
| Modifier and Type | Field and Description |
|---|---|
protected String |
_contentType |
protected File |
_file |
protected String |
_filename |
protected MultiMap<String> |
_headers |
protected String |
_name |
protected OutputStream |
_out |
protected long |
_size |
| Constructor and Description |
|---|
MultiPartInputStream.MultiPart(String name,
String filename) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
close() |
protected void |
createFile() |
void |
delete()
Deletes the underlying storage for a file item, including deleting any
associated temporary disk file.
|
String |
getContentDispositionFilename()
Get the filename from the content-disposition.
|
String |
getContentType()
Gets the content type of this part.
|
File |
getFile()
Get the file, if any, the data has been written to.
|
String |
getHeader(String name)
Returns the value of the specified mime header
as a
String. |
Collection<String> |
getHeaderNames()
Gets the header names of this Part.
|
Collection<String> |
getHeaders(String name)
Gets the values of the Part header with the given name.
|
InputStream |
getInputStream()
Gets the content of this part as an InputStream
|
String |
getName()
Gets the name of this part
|
long |
getSize()
Returns the size of this file.
|
protected void |
open() |
protected void |
setContentType(String contentType) |
protected void |
setHeaders(MultiMap<String> headers) |
protected void |
write(byte[] bytes,
int offset,
int length) |
protected void |
write(int b) |
void |
write(String fileName)
A convenience method to write this uploaded item to disk.
|
protected String _name
protected String _filename
protected File _file
protected OutputStream _out
protected String _contentType
protected long _size
public MultiPartInputStream.MultiPart(String name, String filename) throws IOException
IOExceptionprotected void setContentType(String contentType)
protected void open()
throws FileNotFoundException,
IOException
FileNotFoundExceptionIOExceptionprotected void close()
throws IOException
IOExceptionprotected void write(int b)
throws IOException
IOExceptionprotected void write(byte[] bytes,
int offset,
int length)
throws IOException
IOExceptionprotected void createFile()
throws IOException
IOExceptionpublic String getContentType()
PartgetContentType in interface PartPart.getContentType()public String getHeader(String name)
PartString. If the Part did not include a header
of the specified name, this method returns null.
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.getHeader in interface Partname - a String specifying the
header nameString containing the
value of the requested
header, or null
if the part does not
have a header of that namePart.getHeader(java.lang.String)public Collection<String> getHeaderNames()
PartSome 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 this Part.
getHeaderNames in interface PartCollection of the header
names of this PartPart.getHeaderNames()public Collection<String> getHeaders(String name)
PartAny changes to the returned Collection must not
affect this Part.
Part header names are case insensitive.
getHeaders in interface Partname - the header name whose values to returnCollection of the values of
the header with the given namePart.getHeaders(java.lang.String)public InputStream getInputStream() throws IOException
PartgetInputStream in interface PartIOException - If an error occurs in retrieving the content
as an InputStreamPart.getInputStream()public String getName()
PartgetName in interface PartPart.getName()public long getSize()
PartgetSize in interface Partlong specifying the size of this part, in bytes.Part.getSize()public void write(String fileName) throws IOException
PartThis 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.
write in interface PartfileName - the name of the file to which the stream will be
written. The file is created relative to the location as
specified in the MultipartConfigIOException - if an error occurs.Part.write(java.lang.String)public void delete()
throws IOException
Partdelete in interface PartIOException - if an error occurs.Part.delete()public File getFile()
public String getContentDispositionFilename()
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.