Package com.oorian.apis
Class FileParameter
java.lang.Object
com.oorian.apis.FileParameter
Represents a file to be included in a multipart HTTP request.
Encapsulates the file data, name, content type, and optional parameter name
for use with MultipartRequest subclasses.
-
Constructor Summary
ConstructorsConstructorDescriptionFileParameter(File file) Creates a file parameter from a file, using the file name as the parameter name.FileParameter(String paramName, File file) Creates a file parameter with a form field name and file.FileParameter(String fileName, FileInputStream fileInputStream) Creates a file parameter with a file name and input stream.FileParameter(String paramName, String fileName, FileInputStream fileInputStream) Creates a file parameter with a form field name, file name, and input stream. -
Method Summary
Modifier and TypeMethodDescriptionReturns the MIME content type of the file.getFile()Returns the file object, if one was provided.Returns the input stream for reading the file data.Returns the file name.Returns the form field name for this file parameter.voidsetContentType(String contentType) Sets the content type for this file parameter.
-
Constructor Details
-
FileParameter
Creates a file parameter with a form field name and file.- Parameters:
paramName- the form field name.file- the file to upload.- Throws:
FileNotFoundException- if the file does not exist.
-
FileParameter
Creates a file parameter from a file, using the file name as the parameter name.- Parameters:
file- the file to upload.- Throws:
FileNotFoundException- if the file does not exist.
-
FileParameter
Creates a file parameter with a form field name, file name, and input stream.- Parameters:
paramName- the form field name.fileName- the file name.fileInputStream- the input stream containing the file data.
-
FileParameter
Creates a file parameter with a file name and input stream.- Parameters:
fileName- the file name.fileInputStream- the input stream containing the file data.
-
-
Method Details
-
setContentType
Sets the content type for this file parameter.- Parameters:
contentType- the MIME content type.
-
getParamName
Returns the form field name for this file parameter.- Returns:
- the parameter name.
-
getFileName
Returns the file name.- Returns:
- the file name.
-
getFileInputStream
Returns the input stream for reading the file data.- Returns:
- the file input stream.
- Throws:
FileNotFoundException- if the file cannot be found.
-
getContentType
Returns the MIME content type of the file.- Returns:
- the content type.
-
getFile
Returns the file object, if one was provided.- Returns:
- the file, or
nullif constructed from an input stream.
-