Class TempFileServiceImpl
java.lang.Object
net.datenwerke.gf.service.tempfile.TempFileServiceImpl
- All Implemented Interfaces:
TempFileService
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
-
Constructor Summary
Constructors -
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 file, boolean removeFile) Reads all bytes of a given temporary file into a byte array.
-
Constructor Details
-
TempFileServiceImpl
public TempFileServiceImpl(<any> tempDir)
-
-
Method Details
-
createTempFile
Description copied from interface:TempFileServiceCreates a temporary file in the temp directory configured.- Specified by:
createTempFilein interfaceTempFileService- Returns:
- the temporary file
- Throws:
IOException- if an I/O error occurs
-
createWebAccessibleTempFile
Description copied from interface:TempFileServiceCreates a web-accessible temporary file which can be retrieved by the given id.- Specified by:
createWebAccessibleTempFilein interfaceTempFileService- 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
Description copied from interface:TempFileServiceCreates a temporary file which can be retrieved by the returned identifier (TempFile.getWebId()) using theTempFileServlet.- Specified by:
createWebAccessibleTempFilein interfaceTempFileService- Parameters:
permittedUsers- users allowed to access the temporary file- Throws:
IOException- if an I/O error occurs
-
getTempFileById
Description copied from interface:TempFileServiceGiven an identifier (web-id), retrieves the corresponding temporary file.- Specified by:
getTempFileByIdin interfaceTempFileService- Parameters:
id- the web-id- Returns:
- the temporary file corresponding to the given web-id
-
readTmpFileIntoByteArray
Description copied from interface:TempFileServiceReads 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.- Specified by:
readTmpFileIntoByteArrayin interfaceTempFileService- 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
Description copied from interface:TempFileServiceReads 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.- Specified by:
readTmpFileIntoByteArrayin interfaceTempFileService- Parameters:
file- 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
Description copied from interface:TempFileServiceChecks if the given file is a temporary file, that is, if is located in a temporary file location.- Specified by:
isTmpFilein interfaceTempFileService- Parameters:
path- the file to check- Returns:
- true if the given file is a temporary file
-