Package rife.engine

Class UploadedFile

java.lang.Object
rife.engine.UploadedFile
All Implemented Interfaces:
AutoCloseable, Cloneable

public class UploadedFile extends Object implements Cloneable, AutoCloseable
An UploadedFile instance is created by the web engine when files are uploaded through a multipart request.

The uploaded files can be retrieved through the ElementSupport#getUploadedFile method and its siblings. The web engine does its best to dispose of the temporary file at a convenient time, but the file is not guaranteed to persist after the request. If you want to make sure that the file is deleted, you should call File.delete() yourself when you're finished with the uploaded file.

Since:
1.0
  • Constructor Details

    • UploadedFile

      public UploadedFile(String filename, String contentType)
      Create a new instance.

      This is an internal method, not intended to be used outside RIFE2.

      Parameters:
      filename - the file name that was uploaded
      contentType - the content type of the file
      Since:
      1.0
  • Method Details

    • close

      public void close()
      Close the uploaded file and remove any temporary resources that were created.
      Specified by:
      close in interface AutoCloseable
      Since:
      1.0
    • setTempFile

      public void setTempFile(File tempFile)
      Register a particular file as being the temporary file used for storage.

      This is an internal method, not intended to be used outside RIFE2.

      Parameters:
      tempFile - the temporary file that is being used
      Since:
      1.0
    • setSizeExceeded

      public void setSizeExceeded(boolean exceeded)
      Indicates whether the maximum file size was exceeded during upload.

      This is an internal method, not intended to be used outside RIFE2.

      Parameters:
      exceeded - true if the maximum upload size was exceeded; false otherwise
      Since:
      1.0
    • getContentType

      public String getContentType()
      Retrieves the content type of the file.
      Returns:
      the content type of the uploaded file
      Since:
      1.0
    • getName

      public String getName()
      Retrieves the name of the file that was selected on the client when uploading.
      Returns:
      the name of the original file that was uploaded
      Since:
      1.0
    • getFile

      public File getFile()
      Retrieves the temporary file on the server that was created for the upload.
      Returns:
      the temporary uploaded file
      Since:
      1.0
    • wasSizeExceeded

      public boolean wasSizeExceeded()
      Indicates whether the uploaded file exceeded the file RifeConfig.EngineConfig.getFileUploadSizeLimit() upload size limit}.

      If the limit was exceeded, the temporary file will be null and deleted from the server.

      Returns:
      true if the upload file size limit was exceeded; or

      false otherwise

      Since:
      1.0
    • clone

      public UploadedFile clone()
      Overrides:
      clone in class Object