Package com.coreoz.plume.file.services
Class FileService
java.lang.Object
com.coreoz.plume.file.services.FileService
-
Constructor Summary
ConstructorsConstructorDescriptionFileService(FileMetadataService fileMetadataService, FileStorageService fileStorageService, FileMimeTypeDetector fileMimeTypeDetector, FileConfigurationService fileConfigurationService) -
Method Summary
Modifier and TypeMethodDescriptionadd(FileType fileType, InputStream fileData) Consume the stream to produce a byte array, then calladd(FileType, InputStream, String)add(FileType fileType, InputStream fileData, String fileName) Consume the stream to produce a byte array, then calladd(FileType, InputStream, String, String, String)add(FileType fileType, InputStream fileData, String fileName, String mimeType) Consume the stream to produce a byte array, then calladd(FileType, InputStream, String, String, String)add(FileType fileType, InputStream fileInputStream, String originalName, String fileExtension, String mimeType) Save a new filevoidDelete files having a type that longer exists in theFileTypeenum and can't be linked to stored files.voidDelete unreferenced files.fetchMetadata(String fileUniqueName)
-
Constructor Details
-
FileService
@Inject public FileService(FileMetadataService fileMetadataService, FileStorageService fileStorageService, FileMimeTypeDetector fileMimeTypeDetector, FileConfigurationService fileConfigurationService) throws NoSuchAlgorithmException - Throws:
NoSuchAlgorithmException
-
-
Method Details
-
add
public String add(FileType fileType, InputStream fileInputStream, String originalName, String fileExtension, String mimeType) throws UncheckedIOException Save a new file- Parameters:
fileType- the type of the fileFileTypefileInputStream- the file data stream, that will be closed automatically in this methodoriginalName- the optional (nullable) original name of the file. This won't be the name under the one the file will be savedfileExtension- the optional (nullable) file extensionmimeType- the optional (nullable) mime type- Returns:
- the unique file name of the file. This will be the name under the one the file will be saved
- Throws:
UncheckedIOException- in case the file could not be saved
-
add
Consume the stream to produce a byte array, then calladd(FileType, InputStream, String)- Throws:
UncheckedIOException
-
add
public String add(FileType fileType, InputStream fileData, String fileName, String mimeType) throws UncheckedIOException Consume the stream to produce a byte array, then calladd(FileType, InputStream, String, String, String)- Throws:
UncheckedIOException
-
add
public String add(FileType fileType, InputStream fileData, String fileName) throws UncheckedIOException Consume the stream to produce a byte array, then calladd(FileType, InputStream, String, String, String)- Throws:
UncheckedIOException
-
fetchData
-
fetchMetadata
-
deleteUnreferenced
Delete unreferenced files.- Throws:
UncheckedIOException- is a file could not be deleted. It is possible to retry if the deletion failed.
-
deleteFilesForDeletedTypes
Delete files having a type that longer exists in theFileTypeenum and can't be linked to stored files. This method should be used punctually only when a file type is deleted. Else unwanted files could be deleted in a shared metadata database environment.- Throws:
UncheckedIOException- if a file could not be deleted. This may happen if the file storage service cannot delete the file. It is possible to retry if the deletion failed.
-