Package com.coreoz.plume.file.services
Class FileService
- java.lang.Object
-
- com.coreoz.plume.file.services.FileService
-
@Singleton public class FileService extends Object
-
-
Constructor Summary
Constructors Constructor Description FileService(FileMetadataService fileMetadataService, FileStorageService fileStorageService, FileConfigurationService fileConfigurationService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringadd(FileType fileType, InputStream fileData)Consume the stream to produce a byte array, then calladd(FileType, InputStream, String)Stringadd(FileType fileType, InputStream fileData, String fileName)Consume the stream to produce a byte array, then calladd(FileType, InputStream, String, String, String)Stringadd(FileType fileType, InputStream fileData, String fileName, String mimeType)Consume the stream to produce a byte array, then calladd(FileType, InputStream, String, String, String)Stringadd(FileType fileType, InputStream fileInputStream, String originalName, String fileExtension, String mimeType)Save a new filevoiddeleteUnreferenced()Delete unreferenced files.Optional<InputStream>fetchData(String fileUniqueName)Optional<FileMetadata>fetchMetadata(String fileUniqueName)
-
-
-
Constructor Detail
-
FileService
@Inject public FileService(FileMetadataService fileMetadataService, FileStorageService fileStorageService, FileConfigurationService fileConfigurationService)
-
-
Method Detail
-
add
public String add(FileType fileType, InputStream fileInputStream, String originalName, String fileExtension, String mimeType)
Save a new file- Parameters:
fileType- the type of the fileFileTypefileInputStream- The file data stream, that will be closed automatically in this methodoriginalName- the original name of the file. This won't be the name under the one the file will be savedfileExtension- the file extensionmimeType- the mime type- Returns:
- the unique file name of the file. This will be the name under the one the file will be saved
- Throws:
IOException- in case the file could not be saved
-
add
public String add(FileType fileType, InputStream fileData)
Consume the stream to produce a byte array, then calladd(FileType, InputStream, String)
-
add
public 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
public String add(FileType fileType, InputStream fileData, String fileName)
Consume the stream to produce a byte array, then calladd(FileType, InputStream, String, String, String)
-
fetchData
public Optional<InputStream> fetchData(String fileUniqueName)
-
fetchMetadata
public Optional<FileMetadata> fetchMetadata(String fileUniqueName)
-
deleteUnreferenced
public void deleteUnreferenced()
Delete unreferenced files.- Throws:
IOException- is a file could not be deleted. It is possible to retry if the deletion failed.
-
-