mime: Map Filenames to MIME Types

MIMEタイプ

> library(mime)

バージョン: 0.5


関数名 概略
guess_type Guess the MIME types from filenames
mimemap Tables for mapping filename extensions to MIME types
parse_multipart Parse multipart form data

guess_type

MIMEタイプの推定

Arguments

  • file
  • unknown
  • empty
  • mime_extra
  • subtype
> guess_type(list.files())
  [1] "text/x-markdown"          "text/x-markdown"         
  [3] "text/x-markdown"          "text/x-markdown"         
  [5] "text/x-markdown"          "text/x-markdown"         
  [7] "text/x-markdown"          "text/x-markdown"         
  [9] "text/x-markdown"          "text/x-markdown"         
 [11] "text/x-markdown"          "text/x-markdown"         
 [13] "text/x-markdown"          "text/x-markdown"         
 [15] "text/x-markdown"          "text/x-markdown"         
 [17] "text/x-markdown"          "text/x-markdown"         
 [19] "text/x-markdown"          "text/x-markdown"         
 [21] "text/x-markdown"          "text/x-markdown"         
 [23] "text/x-markdown"          "text/x-markdown"         
 [25] "text/x-markdown"          "text/x-markdown"         
 [27] "text/x-markdown"          "text/x-markdown"         
 [29] "text/x-markdown"          "text/x-markdown"         
 [31] "text/x-markdown"          "text/x-markdown"         
 [33] "text/x-markdown"          "text/x-markdown"         
 [35] "text/x-markdown"          "text/x-markdown"         
 [37] "text/x-markdown"          "text/x-markdown"         
 [39] "text/x-markdown"          "text/x-markdown"         
 [41] "text/x-markdown"          "text/x-markdown"         
 [43] "text/x-markdown"          "text/x-markdown"         
 [45] "text/x-markdown"          "text/x-markdown"         
 [47] "text/x-markdown"          "text/x-markdown"         
 [49] "text/x-markdown"          "text/x-markdown"         
 [51] "text/x-markdown"          "text/x-markdown"         
 [53] "text/x-markdown"          "text/x-markdown"         
 [55] "text/x-markdown"          "text/x-markdown"         
 [57] "text/x-markdown"          "text/x-markdown"         
 [59] "text/x-markdown"          "text/x-markdown"         
 [61] "text/x-markdown"          "text/x-markdown"         
 [63] "text/x-markdown"          "text/x-markdown"         
 [65] "text/x-markdown"          "text/x-markdown"         
 [67] "text/x-markdown"          "text/x-markdown"         
 [69] "text/x-markdown"          "text/x-markdown"         
 [71] "text/x-markdown"          "text/x-markdown"         
 [73] "text/x-markdown"          "text/x-markdown"         
 [75] "text/x-markdown"          "text/x-markdown"         
 [77] "text/x-markdown"          "text/x-markdown"         
 [79] "text/x-markdown"          "text/x-markdown"         
 [81] "text/x-markdown"          "text/x-markdown"         
 [83] "text/x-markdown"          "text/x-markdown"         
 [85] "text/x-markdown"          "text/x-markdown"         
 [87] "text/x-markdown"          "text/x-markdown"         
 [89] "text/x-markdown"          "text/x-markdown"         
 [91] "text/x-markdown"          "text/x-markdown"         
 [93] "text/x-markdown"          "text/x-markdown"         
 [95] "text/x-markdown"          "text/x-markdown"         
 [97] "text/x-markdown"          "text/x-markdown"         
 [99] "text/x-markdown"          "text/x-markdown"         
[101] "text/x-markdown"          "text/x-markdown"         
[103] "text/x-markdown"          "text/x-markdown"         
[105] "text/x-markdown"          "text/x-markdown"         
[107] "text/x-markdown"          "text/x-markdown"         
[109] "text/x-markdown"          "text/x-markdown"         
[111] "text/x-markdown"          "text/x-markdown"         
[113] "application/octet-stream" "text/x-markdown"         
[115] "text/x-markdown"          "text/x-markdown"         
[117] "text/x-markdown"          "text/x-markdown"         
[119] "text/x-markdown"          "text/x-markdown"         
[121] "text/x-markdown"          "text/x-markdown"         
[123] "text/x-markdown"          "text/x-markdown"         
[125] "text/x-markdown"          "text/x-markdown"         
[127] "text/x-markdown"          "text/x-markdown"         
[129] "text/x-markdown"          "text/x-markdown"         
[131] "text/x-markdown"          "text/x-markdown"         
[133] "text/x-markdown"          "text/x-markdown"         
[135] "text/x-markdown"          "text/x-markdown"         
[137] "text/x-markdown"          "text/x-markdown"         
[139] "text/x-markdown"          "text/x-markdown"         
[141] "text/x-markdown"          "text/x-markdown"         
[143] "text/x-markdown"          "text/x-markdown"         
[145] "text/x-markdown"          "text/x-markdown"         
[147] "text/x-markdown"          "text/x-markdown"         
[149] "text/x-markdown"          "text/x-markdown"         
[151] "text/x-markdown"          "text/x-markdown"         
[153] "text/x-markdown"          "text/x-markdown"         
[155] "text/x-markdown"          "text/x-markdown"         
[157] "text/x-markdown"          "text/x-markdown"         
[159] "text/x-markdown"          "text/x-markdown"         
[161] "text/x-markdown"          "text/x-markdown"         
[163] "text/x-markdown"          "text/x-markdown"         
[165] "text/x-markdown"          "text/x-markdown"         
[167] "text/x-markdown"          "text/x-markdown"         
[169] "text/x-markdown"          "text/x-markdown"         
[171] "text/x-markdown"          "text/x-markdown"         
[173] "text/x-markdown"          "text/x-markdown"         
[175] "text/x-markdown"          "text/x-markdown"         
[177] "text/x-markdown"          "text/x-markdown"         
[179] "text/x-markdown"          "text/x-markdown"         
[181] "text/x-markdown"          "text/x-markdown"         
[183] "text/x-markdown"          "text/x-markdown"         
[185] "text/x-markdown"          "text/x-markdown"         
[187] "text/x-markdown"          "text/x-markdown"         
[189] "text/x-markdown"          "text/x-markdown"         
[191] "text/x-markdown"          "text/x-markdown"         
[193] "text/x-markdown"          "text/x-markdown"         
[195] "text/x-markdown"          "text/x-markdown"         
[197] "text/x-markdown"          "text/x-markdown"         
[199] "text/x-markdown"          "text/x-markdown"         
[201] "text/x-markdown"          "text/x-markdown"         
[203] "text/x-markdown"          "text/x-markdown"         
[205] "text/x-markdown"          "text/x-markdown"         
[207] "text/x-markdown"          "text/x-markdown"         
[209] "text/x-markdown"          "text/x-markdown"         
[211] "text/x-markdown"          "text/x-markdown"         
[213] "text/x-markdown"          "text/x-markdown"         
[215] "text/x-markdown"          "text/x-markdown"         
[217] "text/x-markdown"          "text/x-markdown"         
[219] "text/x-markdown"          "text/x-markdown"         
[221] "text/x-markdown"          "text/x-markdown"         
[223] "text/x-markdown"          "text/x-markdown"         
[225] "text/x-markdown"          "text/x-markdown"         
[227] "text/x-markdown"          "text/x-markdown"         
[229] "application/octet-stream" "text/x-markdown"         
[231] "text/x-markdown"          "text/x-markdown"         
[233] "text/x-markdown"          "text/x-markdown"         
[235] "text/x-markdown"          "text/x-markdown"         
[237] "text/x-markdown"          "text/x-markdown"         
[239] "text/x-markdown"          "text/x-markdown"         
[241] "text/x-markdown"          "text/x-markdown"         
[243] "text/x-markdown"          "text/x-markdown"         
[245] "text/x-markdown"          "text/x-markdown"         
[247] "text/x-markdown"          "text/x-markdown"         
[249] "text/x-markdown"          "text/x-markdown"         
[251] "text/x-markdown"          "text/x-markdown"         
[253] "text/x-markdown"          "text/x-markdown"         
[255] "text/x-markdown"          "text/x-markdown"         
[257] "text/x-markdown"          "text/x-markdown"         
[259] "text/x-markdown"          "text/x-markdown"         
[261] "text/x-markdown"
> guess_type("Makefile")
[1] "text/plain"
> guess_type("Makefile", empty = "text/plain")
[1] "text/plain"
> guess_type(c("a.md", "b.R"), mime_extra = NULL)
[1] "application/octet-stream" "application/octet-stream"
> guess_type(c("abc.html", "def.htm"), subtype = c("charset=UTF-8", ""))
[1] "text/html; charset=UTF-8" "text/html"

mimemap

> as.list(mimemap) %>% head() %>% str()
List of 6
 $ ez     : chr "application/andrew-inset"
 $ anx    : chr "application/annodex"
 $ atom   : chr "application/atom+xml"
 $ atomcat: chr "application/atomcat+xml"
 $ atomsrv: chr "application/atomserv+xml"
 $ lin    : chr "application/bbolin"
> mimemap["pdf"]
              pdf 
"application/pdf"
> mime:::mimeextra
                   geojson                         md 
"application/vnd.geo+json"          "text/x-markdown" 
                  markdown                          r 
         "text/x-markdown"               "text/plain" 
                        rd                        rmd 
              "text/plain"          "text/x-markdown"

parse_multipart