Class FileRequestParameter
- java.lang.Object
-
- com.adobe.aemds.guide.submitutils.FileRequestParameter
-
- All Implemented Interfaces:
RequestParameter
public class FileRequestParameter extends java.lang.Object implements RequestParameter
Created with IntelliJ IDEA. User: syr Date: 1/20/14 Time: 12:51 PM To change this template use File | Settings | File Templates.
-
-
Constructor Summary
Constructors Constructor Description FileRequestParameter(java.lang.String fileName, byte[] fileBytes, java.lang.String contentType)
FileRequestParameter(java.lang.String fileName, byte[] fileBytes, java.lang.String contentType, java.lang.String uri)
FileRequestParameter(java.lang.String fileName, Resource fileResource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
get()
Returns the contents of the parameter as an array of bytes.java.lang.String
getContentType()
Returns the content type passed by the browser ornull
if not defined.java.lang.String
getFileName()
Returns the original filename in the client's filesystem, as provided by the browser (or other client software).java.io.InputStream
getInputStream()
Returns an InputStream that can be used to retrieve the contents of the file.java.lang.String
getName()
long
getSize()
Returns the size in bytes of the parameter.java.lang.String
getString()
Returns the contents of the parameter as a String, using the default character encoding.java.lang.String
getString(java.lang.String encoding)
Returns the contents of the parameter as a String, using the specified encoding.java.lang.String
getUri()
boolean
isFormField()
Determines whether or not this instance represents a simple form field or an uploaded file.void
setUri(java.lang.String uri)
-
-
-
Constructor Detail
-
FileRequestParameter
public FileRequestParameter(java.lang.String fileName, Resource fileResource)
-
FileRequestParameter
public FileRequestParameter(java.lang.String fileName, byte[] fileBytes, java.lang.String contentType)
-
FileRequestParameter
public FileRequestParameter(java.lang.String fileName, byte[] fileBytes, java.lang.String contentType, java.lang.String uri)
-
-
Method Detail
-
getInputStream
public java.io.InputStream getInputStream()
Description copied from interface:RequestParameter
Returns an InputStream that can be used to retrieve the contents of the file.Each call to this method returns a new
InputStream
to the request parameter data. Make sure to close the stream to prevent leaking resources.- Specified by:
getInputStream
in interfaceRequestParameter
- Returns:
- An InputStream that can be used to retrieve the contents of the file.
-
getFileName
public java.lang.String getFileName()
Description copied from interface:RequestParameter
Returns the original filename in the client's filesystem, as provided by the browser (or other client software). In most cases, this will be the base file name, without path information. However, some clients, such as the Opera browser, do include path information.- Specified by:
getFileName
in interfaceRequestParameter
- Returns:
- The original filename in the client's filesystem.
-
isFormField
public boolean isFormField()
Description copied from interface:RequestParameter
Determines whether or not this instance represents a simple form field or an uploaded file.- Specified by:
isFormField
in interfaceRequestParameter
- Returns:
true
if the instance represents a simple form field;false
if it represents an uploaded file.
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceRequestParameter
- Returns:
- the name of this
RequestParameter
-
getContentType
public java.lang.String getContentType()
Description copied from interface:RequestParameter
Returns the content type passed by the browser ornull
if not defined.- Specified by:
getContentType
in interfaceRequestParameter
- Returns:
- The content type passed by the browser or
null
if not defined.
-
get
public byte[] get()
Description copied from interface:RequestParameter
Returns the contents of the parameter as an array of bytes.- Specified by:
get
in interfaceRequestParameter
- Returns:
- The contents of the parameter as an array of bytes.
-
getString
public java.lang.String getString()
Description copied from interface:RequestParameter
Returns the contents of the parameter as a String, using the default character encoding. This method usesRequestParameter.get()
to retrieve the contents of the item.- Specified by:
getString
in interfaceRequestParameter
- Returns:
- The contents of the parameter, as a string.
-
getString
public java.lang.String getString(java.lang.String encoding)
Description copied from interface:RequestParameter
Returns the contents of the parameter as a String, using the specified encoding. This method uses linkRequestParameter.get()
to retrieve the contents of the item.- Specified by:
getString
in interfaceRequestParameter
- Parameters:
encoding
- The character encoding to use.- Returns:
- The contents of the parameter, as a string.
-
getSize
public long getSize()
Description copied from interface:RequestParameter
Returns the size in bytes of the parameter.- Specified by:
getSize
in interfaceRequestParameter
- Returns:
- The size in bytes of the parameter.
-
getUri
public java.lang.String getUri()
-
setUri
public void setUri(java.lang.String uri)
-
-