mime: Map Filenames to MIME Types

2025-03-17

Title Map Filenames to MIME Types
Version 0.13.1
Description Guesses the MIME type from a filename extension using the data derived from /etc/mime.types in UNIX-type systems.
Imports tools
License GPL
URL https://github.com/yihui/mime
BugReports https://github.com/yihui/mime/issues
Author Yihui Xie ORCID iD [aut, cre], Jeffrey Horner [ctb], Beilei Bian [ctb]

R-CMD-check CRAN release

This is an R package for mapping filename extensions to MIME types, based on the data derived from /etc/mime.types.

# installation
install.packages('mime')

library(mime)
guess_type(c('a/b/c.html', 'd.pdf', 'e.odt', 'foo.docx', 'tex'))
# [1] "text/html"                                                              
# [2] "application/pdf"                                                        
# [3] "application/vnd.oasis.opendocument.text"                                
# [4] "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
# [5] "text/x-tex"

Appendix

To cite the package mime in publications, please use:

Xie Y (2025). mime: Map Filenames to MIME Types. R package version 0.13.1, https://github.com/yihui/mime.

@Manual{,
  title = {mime: Map Filenames to MIME Types},
  author = {Yihui Xie},
  year = {2025},
  note = {R package version 0.13.1},
  url = {https://github.com/yihui/mime},
}