Interface File
- All Superinterfaces:
Comparable<StoreElement>,MediaElement,StoreElement,Workflowable
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 Summary
Modifier and TypeMethodDescriptionlonggetCrc()Get the crc of the file or -1 if crc isn't setGet the description of the current media.Get the encoding of the current file-mediaGet the extension.@Nullable RevisionReturn file content revision ornullif no content exits.Returns the file content as anInputStream.Get the language of the currentFile.@Nullable MimeTypeGet the mime-type.Returns the parsed file content, if, elseMedia.getParseFile()== truenull.@org.jetbrains.annotations.Nullable byte[]Get a small preview/thumbnail image of this picturelonggetSize()Get the size of the file or -1 if size isn't setvoidsetDescription(String description) Set the description of the current media.voidsetEncoding(String encoding) Set the encoding of the current file-mediavoidsetExtension(String extension) Set the Extension The extension is also set by the upload methods.voidsetFile(long length, InputStream file, String extension) Set new data for the file including its extension and content length.voidsetPreviewImage(@org.jetbrains.annotations.Nullable byte[] bytes) Set a the image data source to create a preview-thumbnail from.Methods inherited from interface java.lang.Comparable
compareToMethods inherited from interface de.espirit.firstspirit.access.store.StoreElement
appendChild, appendChildBefore, delete, exportStoreElement, getChildCount, getChildIndex, getChildren, getChildren, getChildren, getChildren, getCreateWorkflowPermission, getDefinedPrincipalPermissions, getEditor, getElementType, getFirstChild, getIncomingReferences, getInheritedPrincipalPermissions, getLastChanged, getName, getNextSibling, getOutgoingReferences, getParent, getPermission, getPermission, getPermission, getPreviousSibling, getProject, getReferenceName, getReferences, getReferences, getStore, getTreePermission, getWorkflowPermission, getWorkflowPermissions, getWriteLock, hasIncomingReferences, hasPermissions, importStoreElement, importStoreElements, inheritWorkflowPermission, isDeleted, isExportSupported, isFolder, isImportSupported, isLocked, isLockedOnServer, isLockSupported, isPermissionSupported, isWorkflowAllowed, isWorkflowSupported, refresh, removeAllWorkflowPermissions, removeChild, removePermission, removePermission, removePermission, removeWorkflowPermission, replaceChild, save, save, save, setInheritWorkflowPermission, setLock, setLock, setPermission, setPermission, setPermission, setWorkflowPermission, setWorkflowPermissions, setWriteLock, toXml, toXml, toXmlMethods inherited from interface de.espirit.firstspirit.access.Workflowable
getColor, getTask, hasTask, removeTask, setColor, setTask
-
Method Details
-
getLanguage
Language getLanguage()Get the language of the currentFile.- Returns:
- language of the file-media as object
- Since:
- 3.0
-
getInputStream
Returns the file content as anInputStream.- Throws:
IOException- Since:
- 4.0
-
setFile
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 bytesfile- as anInputStreamextension- the file extension- Throws:
IOException- Since:
- 4.1.10
- See Also:
-
getPreviewImage
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 ornullto 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
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
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
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
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
Return file content revision ornullif 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
-1for unkonwn - Since:
- 4.0
-
getParsedFile
Returns the parsed file content, if, elseMedia.getParseFile()== truenull.- Returns:
- the parsed file content or
null - Throws:
ParsingErrorIOException- Since:
- 4.0
-