@OpenApiAll
public class FileAttachmentsHelper
extends java.lang.Object
| Constructor and Description |
|---|
FileAttachmentsHelper() |
| Modifier and Type | Method and Description |
|---|---|
static Comment |
createAttachedFileElement(Element owner)
Creates a comment stereotyped with AttachedFile stereotype.
|
static java.io.File |
extractToDirectory(java.io.File directory,
Element element) |
static java.io.InputStream |
getStoredFileInputStream(Element element) |
static void |
removeStoredFile(Element element)
Removes any file that has been previously stored using
storeFile(Element, File) or storeFileToAttachedFile(Comment, File) methods. |
static boolean |
storeFile(Element element,
java.io.File file)
Stores a file inside the element.
|
static boolean |
storeFileToAttachedFile(Comment attachedFileElement,
java.io.File file)
Attaches provided file to the AttachedFile element and updates informative element properties that are visible to the user:
name, size, dateAdded, dateModified, author.
|
public static boolean storeFile(Element element, java.io.File file) throws java.io.IOException
element - any elementfile - existing file to storejava.io.IOExceptionpublic static boolean storeFileToAttachedFile(Comment attachedFileElement, @CheckForNull java.io.File file)
attachedFileElement - stereotyped comment created with the createAttachedFileElement(Element) method.file - existing file to store.public static void removeStoredFile(Element element)
storeFile(Element, File) or storeFileToAttachedFile(Comment, File) methods.element - element to remove attachment from@CheckForNull public static java.io.InputStream getStoredFileInputStream(Element element)
element - element that has a file stored with storeFile(Element, File) or storeFileToAttachedFile(Comment, File) method.@CheckForNull
public static java.io.File extractToDirectory(java.io.File directory,
Element element)
throws java.io.IOException
directory - directory to save the attachment to. It will be created if not yet existselement - element that has a file stored with storeFile(Element, File) or storeFileToAttachedFile(Comment, File) method.java.io.IOException - when saving of the file fails