Package systems.dmx.files
Class UploadedFile
- java.lang.Object
-
- systems.dmx.files.UploadedFile
-
public class UploadedFile extends Object
An uploaded file.Files are uploaded via the REST API by POSTing
multipart/form-data
to a resource method which consumesmultipart/form-data
and has UploadedFile as its entity parameter.- Author:
- Jörg Richter
-
-
Constructor Summary
Constructors Constructor Description UploadedFile(String name, long size, InputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
getInputStream()
Returns an InputStream that can be used to retrieve the contents of the uploaded file.String
getName()
Returns the original filename in the client's filesystem, as provided by the browser (or other client software).long
getSize()
String
getString()
Returns the contents of the uploaded file as a String, using the default character encoding.String
getString(String encoding)
Returns the contents of the uploaded file as a String, using the given encoding.void
setBuffered()
Transforms the InputStream into a BufferedInputStream and sets a mark.String
toString()
Returns the contents of the uploaded file as an array of bytes.
-
-
-
Constructor Detail
-
UploadedFile
public UploadedFile(String name, long size, InputStream in)
-
-
Method Detail
-
getName
public String getName()
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.
-
getSize
public long getSize()
-
getInputStream
public InputStream getInputStream()
Returns an InputStream that can be used to retrieve the contents of the uploaded file.
-
setBuffered
public void setBuffered()
Transforms the InputStream into a BufferedInputStream and sets a mark. This allows to call reset() later on in order to read the stream's bytes again. Should be called before you read any bytes from the stream.Call
getInputStream()
after callingsetBuffered()
in order to get the actual BufferedInputStream.Calling reset() without calling
setBuffered()
before throws an IOException.
-
getString
public String getString()
Returns the contents of the uploaded file as a String, using the default character encoding.
-
getString
public String getString(String encoding)
Returns the contents of the uploaded file as a String, using the given encoding.
-
-