Map Filenames to MIME Types

Guesses the MIME type from a filename extension using the data derived from /etc/mime.types in UNIX-type systems.


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

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"

You can install the stable version from CRAN, or the development version from XRAN:

# CRAN version
install.packages('mime', repos = 'https://cran.rstudio.com')
# development version
install.packages('mime', repos = 'http://yihui.name/xran')

News

     CHANGES IN mime VERSION 0.5

MAJOR CHANGES

o the package license was changed from GPL-2 to GPL

     CHANGES IN mime VERSION 0.4

NEW FEATURES

o added a new content type: .geojson -> application/vnd.geo+json (thanks, @dmpe, #3)

BUG FIXES

o guess_type() may fail on Windows when the file paths are too long (#2)

     CHANGES IN mime VERSION 0.3

NEW FEATURES

o added a few more content types

     CHANGES IN mime VERSION 0.2

NEW FEATURES

o added a function parse_multipart() to parse multipart form data submitted via HTTP POST

     CHANGES IN mime VERSION 0.1.2

BUG FIXES

o guess_type() returned wrong values for filenames without extensions: it should have used the 'empty' argument.

     CHANGES IN mime VERSION 0.1.1

BUG FIXES

o mime::guess_type() may not work when mime is loaded but not attached, because R does not load the mimemap data in this case. Now mimemap is exported in the package namespace.

     CHANGES IN mime VERSION 0.1

NEW FEATURES

o The initial version of mime. The main function is mime::guess_type().

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("mime")

0.5 by Yihui Xie, a year ago


https://github.com/yihui/mime


Report a bug at https://github.com/yihui/mime/issues


Browse source code at https://github.com/cran/mime


Authors: Jeffrey Horner [ctb], Yihui Xie [aut, cre]


Documentation:   PDF Manual  


Task views: Web Technologies and Services


GPL license


Imports tools


Imported by RSocrata, boxr, crul, gmailr, httr, jug, markdown, opencpu, rmarkdown, servr, shiny, sofa, solvebio.


See at CRAN