Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Add extensions to convert mimeTypes #101

Merged
merged 1 commit into from
Apr 22, 2022
Merged

Add extensions to convert mimeTypes #101

merged 1 commit into from
Apr 22, 2022

Conversation

@Goooler Goooler added this to the 1.6.0 milestone Apr 22, 2022
Comment on lines +99 to +100
fun String.extension2MimeType(): String? =
MimeTypeMap.getSingleton().getMimeTypeFromExtension(lowercase())
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal fun String.extension2MimeType(): String? {
  return MimeTypeMap.getSingleton().getMimeTypeFromExtension(lowercase()) ?: allFileTypes[this]
}

Comment on lines +102 to +103
fun String.mimeType2Extension(): String? =
MimeTypeMap.getSingleton().getExtensionFromMimeType(lowercase())
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal fun String.mimeType2Extension(): String? {
  return MimeTypeMap.getSingleton().getExtensionFromMimeType(lowercase())
    ?: allFileTypes.filterValues { it == this }.keys.firstOrNull()
}

@Goooler Goooler merged commit 19d1f54 into trunk Apr 22, 2022
@Goooler Goooler deleted the mime branch April 22, 2022 06:22
@Goooler Goooler restored the mime branch April 22, 2022 06:22
@Goooler Goooler deleted the mime branch April 22, 2022 06:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant