Class 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 consumes multipart/form-data and has UploadedFile as its entity parameter.

    Jörg Richter
    • Constructor Detail

    • 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 calling setBuffered() 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.
      • toString

        public String toString()
        Returns the contents of the uploaded file as an array of bytes. TODO public byte[] getBytes() { return fileItem.get(); }
        toString in class Object