Class MimeTypesDetector
- java.lang.Object
-
- com.coreoz.plume.file.services.mimetype.MimeTypesDetector
-
- All Implemented Interfaces:
FileMimeTypeDetector
public class MimeTypesDetector extends Object implements FileMimeTypeDetector
AFileMimeTypeDetectorusing the library mime-types.
-
-
Constructor Summary
Constructors Constructor Description MimeTypesDetector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringguessMimeType(String fileName, PeekingInputStream fileData)Find the corresponding mime type for the file name.
Usage:
-
-
-
Method Detail
-
guessMimeType
@Nullable public String guessMimeType(String fileName, PeekingInputStream fileData) throws IOException
Description copied from interface:FileMimeTypeDetectorFind the corresponding mime type for the file name.
Usage:
InputStream fileStream = ... // First you need the initial file stream PeekingInputStream filePeekingStream = new PeekingInputStream(fileStream); String mimeType = guessMimeType(fileName, filePeekingStream); otherOperationsWithStream(filePeekingStream.peekedStream());- Specified by:
guessMimeTypein interfaceFileMimeTypeDetector- Parameters:
fileName- the file namefileData- The file input stream data wrapped inside a PeekingInputStream- Returns:
- the mime type guessed, null if no one is found
- Throws:
IOException- if the base input stream cannot be read
-
-