Interface FileApi
-
public interface FileApi
Public API for the management of file upload/download.
Note: Resources are always referenced by their id, represented as aUUID
. A resource id is a UUID which uniquely identifies the resource.
When the resource is referenced differently (not with the id) it will be specified in the parameter name and its documentation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FileInfo
addFile(AddFileRequest addFileRequest)
Add a new file to the temporary upload folder.FileInfo
addFile(String fileName, File file, boolean skipSecurity)
Add a new file to the temporary upload folder.void
cleanTemporaryDirectory(long timeToLive)
Removes files that are older than the given time to live.void
deleteFile(UUID fileId)
Delete file with IDboolean
exists(UUID fileId)
Returns true if a file with givenid
exists.InputStream
getFileAsStream(UUID fileId)
Returns the content of given file from temporary upload folder or attachments folder as an input stream.byte[]
getFileContent(UUID fileId)
Returns contents of a fileFile
getFileDirectory()
Returns the directoryFile
where all files are placed in.FileInfo
getFileInfo(UUID fileId)
Returns the information about a file with its ID.FileInfo
getFileInfoFromUrl(String fileUrl)
Returns the information about the file for the given url.String
getFileName(UUID fileId)
Returns the name of the file.void
touchFile(UUID fileId)
Update the lastModified timestamp of the file
-
-
-
Method Detail
-
addFile
FileInfo addFile(AddFileRequest addFileRequest)
Add a new file to the temporary upload folder.- Parameters:
addFileRequest
- the properties of the file to be added- Returns:
- the
FileInfo
of the file if it was added without error
-
addFile
FileInfo addFile(String fileName, File file, boolean skipSecurity)
Add a new file to the temporary upload folder.- Parameters:
fileName
- the name of the file to addfile
- the file to addskipSecurity
- If true, no security check will be done.- Returns:
- the file identifier if it was added without error
-
getFileAsStream
InputStream getFileAsStream(UUID fileId)
Returns the content of given file from temporary upload folder or attachments folder as an input stream. Keep in mind to useAttachmentApi.getAttachmentContent(java.util.UUID)
instead of this endpoint when you want to get the file of an attachment. A File and its id can be temporary so it's possible this endpoint will not get you the desired file.- Parameters:
fileId
- theid
of the file- Returns:
- the content as
InputStream
-
getFileDirectory
File getFileDirectory()
Returns the directoryFile
where all files are placed in.- Returns:
- the directory
-
getFileInfo
FileInfo getFileInfo(UUID fileId)
Returns the information about a file with its ID.- Parameters:
fileId
- The ID of the file represented as aUUID
- Returns:
- The information about the file
-
getFileContent
byte[] getFileContent(UUID fileId)
Returns contents of a file- Parameters:
fileId
- The ID of the file represented as aUUID
- Returns:
- a
byte
-
getFileInfoFromUrl
FileInfo getFileInfoFromUrl(String fileUrl)
Returns the information about the file for the given url.- Parameters:
fileUrl
- the url of the file to get- Returns:
- the
FileInfo
-
getFileName
String getFileName(UUID fileId)
Returns the name of the file.- Parameters:
fileId
- The ID of the file for which to get name- Returns:
- a file name
-
cleanTemporaryDirectory
void cleanTemporaryDirectory(long timeToLive)
Removes files that are older than the given time to live.- Parameters:
timeToLive
- Duration that a file can exist in milliseconds before it is removed
-
exists
boolean exists(UUID fileId)
Returns true if a file with givenid
exists.- Parameters:
fileId
- theid
of the issue- Returns:
- true if a file with given
id
exists,false
otherwise
-
touchFile
void touchFile(UUID fileId)
Update the lastModified timestamp of the file- Parameters:
fileId
- the Id of the file
-
deleteFile
void deleteFile(UUID fileId)
Delete file with ID- Parameters:
fileId
- the Id of the file
-
-