Interface TempFileService
- All Known Implementing Classes:
TempFileServiceImpl
public interface TempFileService
-
Method Summary
Modifier and TypeMethodDescriptionCreates a temporary file in the temp directory configured.createWebAccessibleTempFile(String id, User... permittedUsers) Creates a web-accessible temporary file which can be retrieved by the given id.createWebAccessibleTempFile(User... permittedUsers) Creates a temporary file which can be retrieved by the returned identifier (TempFile.getWebId()) using theTempFileServlet.Given an identifier (web-id), retrieves the corresponding temporary file.booleanChecks if the given file is a temporary file, that is, if is located in a temporary file location.byte[]readTmpFileIntoByteArray(Path path) Reads all bytes of a given temporary file into a byte array.byte[]readTmpFileIntoByteArray(Path path, boolean removeFile) Reads all bytes of a given temporary file into a byte array.
-
Method Details
-
createTempFile
Creates a temporary file in the temp directory configured.- Returns:
- the temporary file
- Throws:
IOException- if an I/O error occurs
-
createWebAccessibleTempFile
Creates a web-accessible temporary file which can be retrieved by the given id.- Parameters:
id- the web-id of the temporary file.permittedUsers- users allowed to access the temporary file- Returns:
- the web-accessible temp file
- Throws:
IOException- if an I/O error occurs
-
createWebAccessibleTempFile
Creates a temporary file which can be retrieved by the returned identifier (TempFile.getWebId()) using theTempFileServlet.- Parameters:
permittedUsers- users allowed to access the temporary file- Throws:
IOException- if an I/O error occurs
-
getTempFileById
Given an identifier (web-id), retrieves the corresponding temporary file.- Parameters:
id- the web-id- Returns:
- the temporary file corresponding to the given web-id
-
readTmpFileIntoByteArray
Reads all bytes of a given temporary file into a byte array. Note that this method is intended for simple cases where it is convenient to read all bytes into a byte array. It is not intended for reading in large files.- Parameters:
path- the temporary file to read- Returns:
- the content of the temporary file as a byte array
- Throws:
IOException- if an I/O error occurs
-
readTmpFileIntoByteArray
Reads all bytes of a given temporary file into a byte array. Note that this method is intended for simple cases where it is convenient to read all bytes into a byte array. It is not intended for reading in large files.- Parameters:
path- the temporary file to readremoveFile- true if the temporary file should be deleted after reading into a byte array- Returns:
- the content of the temporary file as a byte array
- Throws:
IOException- if an I/O error occurs
-
isTmpFile
Checks if the given file is a temporary file, that is, if is located in a temporary file location.- Parameters:
path- the file to check- Returns:
- true if the given file is a temporary file
-