Skip to contents

Determines a suitable file extension from a MIME type, based i.a. on mime::mimemap and mime:::mimeextra. In case of multiple matches, the first one is returned and a warning is printed (unless quiet = TRUE).

Usage

mime_to_ext(mime_type, quiet = FALSE)

Arguments

mime_type

MIME type to determine the file extension for. A character scalar.

quiet

Whether or not to suppress printing status output from internal processing.

Value

A character scalar.

Examples

pal::mime_to_ext("application/json")
#> [1] "json"
pal::mime_to_ext("audio/mpeg")
#> Warning: The MIME type "audio/mpeg" maps to multiple file extensions ("mpga", "mpega", "mp2", "mp3", and "m4a"). Simply the first one is returned.
#> [1] "mpga"