Package com.blackrook.small.multipart
Class Part
java.lang.Object
com.blackrook.small.multipart.Part
Multipart part that is part of a multiform request.
- Author:
- Matthew Tropiano
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetFile()
Returns a handle to this file, or null if not a file.long
Returns the length of this part.getName()
getValue()
boolean
isFile()
Returns if this part refers to a file.void
setContentType
(String contentType) Sets the content type on this part.void
Sets the file on this part.void
setFileName
(String fileName) Sets the file name of this Part.void
Sets the name of this Part.void
Sets the value of this part, if not a file.
-
Constructor Details
-
Part
public Part()
-
-
Method Details
-
getName
- Returns:
- the name of this part (parameter name).
-
isFile
public boolean isFile()Returns if this part refers to a file.- Returns:
- true if so, false if not.
-
getFileName
- Returns:
- the original file name of the file, or null if not a file.
- See Also:
-
getFile
Returns a handle to this file, or null if not a file.NOTE: You cannot guarantee that this file handle will be valid after the handled request, as it may be deleted after the controller processes the POST!
If you need to keep this file around, it should be copied to another file!
- Returns:
- the file on this part, or null if not a file.
- See Also:
-
getLength
public long getLength()Returns the length of this part. If file, this is the file length in bytes. If value, this is the value length in characters.- Returns:
- the length.
-
getContentType
- Returns:
- the content type of the uploaded file, or null if not a file.
- See Also:
-
getValue
- Returns:
- this part's value, if it is not a file.
-
setName
Sets the name of this Part.- Parameters:
name
- the name.
-
setFileName
Sets the file name of this Part.- Parameters:
fileName
- the file name.
-
setFile
Sets the file on this part.- Parameters:
file
- the file descriptor.
-
setContentType
Sets the content type on this part.- Parameters:
contentType
- the content type (MIME type)
-
setValue
Sets the value of this part, if not a file.- Parameters:
value
- the parameter value.
-