Skip to content

Commit

Permalink
chore: Rename method with guess
Browse files Browse the repository at this point in the history
  • Loading branch information
tevincent committed Nov 14, 2024
1 parent 5b38986 commit 9e2e69e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ enum class FileType(val icon: ImageVector, private val colorLight: Color, privat
}

companion object {
fun getMimeTypeFromFileName(fileName: String): String? {
//TODO Move this method in Core2
fun guessMimeTypeFromFileName(fileName: String): String? {
return fileName.extractExtension()?.let { extension ->
MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
}
}

fun guessFromFileName(fileName: String): FileType {
val mimeType = getMimeTypeFromFileName(fileName) ?: return UNKNOWN
val mimeType = guessMimeTypeFromFileName(fileName) ?: return UNKNOWN
return guessFromMimeType(mimeType)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ImportationFilesManager @Inject constructor(
uid = fileToImport.fileName,
fileName = fileToImport.fileName,
fileSize = fileToImport.fileSizeInBytes,
mimeType = FileType.getMimeTypeFromFileName(fileToImport.fileName),
mimeType = FileType.guessMimeTypeFromFileName(fileToImport.fileName),
localPath = copiedFile.toUri().toString(),
)
)
Expand Down

0 comments on commit 9e2e69e

Please sign in to comment.