All Superinterfaces:
Comparable<StoreElement>, MediaElement, StoreElement, Workflowable

public interface File extends MediaElement
This interface provides methods to handle a media object of type FILE from the MediaStore.

A File can be retrieved from a type Media object by calling the getFile()-method if it is not a picture. A language must be provided within the method call.

Since:
3.0
See Also:
  • Method Details

    • getLanguage

      Language getLanguage()
      Get the language of the current File.
      Returns:
      language of the file-media as object
      Since:
      3.0
    • getInputStream

      InputStream getInputStream() throws IOException
      Returns the file content as an InputStream.
      Throws:
      IOException
      Since:
      4.0
    • setFile

      void setFile(long length, InputStream file, String extension) throws IOException
      Set new data for the file including its extension and content length.

      Calling this method will also upload the content to the FirstSpirit server. Be aware that the uploaded data must be stored by using the save()-method.

      Parameters:
      length - content length in bytes
      file - as an InputStream
      extension - the file extension
      Throws:
      IOException
      Since:
      4.1.10
      See Also:
    • getPreviewImage

      @Nullable @org.jetbrains.annotations.Nullable byte[] getPreviewImage() throws IOException
      Get a small preview/thumbnail image of this picture
      Returns:
      preview the picture-media preview image or null
      Throws:
      IOException - if any error occurs while obtaining the preview image stream
      Since:
      5.0
    • setPreviewImage

      void setPreviewImage(@Nullable @org.jetbrains.annotations.Nullable byte[] bytes)
      Set a the image data source to create a preview-thumbnail from. This could be a non-scaled instance, down-scaling to fit into 100x100 pixels is then done automatically.
      Parameters:
      bytes - the image data or null to reset the preview image
      Since:
      5.0
    • getEncoding

      String getEncoding()
      Get the encoding of the current file-media
      Returns:
      encoding of the file-media e.g. "ISO-8859-1"
      Since:
      3.0
    • setEncoding

      void setEncoding(String encoding)
      Set the encoding of the current file-media
      Parameters:
      encoding - new encoding of the file-media e.g. "ISO-8859-1"
      Since:
      3.0
    • getDescription

      String getDescription()
      Get the description of the current media.
      Returns:
      description of the media
      Since:
      3.0
    • setDescription

      void setDescription(String description)
      Set the description of the current media.
      Parameters:
      description - new description of the media
      Since:
      3.0
    • getExtension

      String getExtension()
      Get the extension.
      Returns:
      the extension
      Since:
      3.0
    • getMimeType

      @Nullable @Nullable MimeType getMimeType()
      Get the mime-type. The Mime-Type detection is done in unix style magic-mime lookup and some fallback mechanisms.
      Returns:
      the mime-type
      Since:
      5.0
    • setExtension

      void setExtension(String extension)
      Set the Extension The extension is also set by the upload methods. The extension is determined by a mime-type detection and a reverse mime-type to extension mapping. e.g. if you rename a pdf to doc it should not be possible to upload this a file as doc file because its not a doc. You could not treat any pdf as doc and upload it through the api with the extension doc - this should not be accepted.
      Parameters:
      extension - the extension
      Since:
      3.0
    • getFileRevision

      @Nullable @Nullable Revision getFileRevision()
      Return file content revision or null if no content exits.
      Returns:
      the file revision
      Since:
      4.0
    • getSize

      long getSize()
      Get the size of the file or -1 if size isn't set
      Returns:
      the size in bytes
      Since:
      3.0
    • getCrc

      long getCrc()
      Get the crc of the file or -1 if crc isn't set
      Returns:
      the crc or -1 for unkonwn
      Since:
      4.0
    • getParsedFile

      TemplateDocument getParsedFile() throws ParsingError, IOException
      Returns the parsed file content, if Media.getParseFile() == true, else null.
      Returns:
      the parsed file content or null
      Throws:
      ParsingError
      IOException
      Since:
      4.0