Description Usage Arguments Examples
Look up in the mimemap
table for the MIME types based on the
extensions of the given filenames.
1 2 3 4 5 6 7 | guess_type(
file,
unknown = "application/octet-stream",
empty = "text/plain",
mime_extra = mimeextra,
subtype = ""
)
|
file |
a character vector of filenames, or filename extensions |
unknown |
the MIME type to return when the file extension was not found in the table |
empty |
the MIME type for files that do not have extensions |
mime_extra |
a named character vector of the form |
subtype |
a character vector of MIME subtypes, which should be of the
same length as |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | library(mime)
# well-known file types
guess_type(c("a/b/c.html", "d.pdf", "e.odt", "foo.docx", "tex"))
# not in the standard table, but in mimeextra
guess_type(c("a.md", "b.R"), mime_extra = NULL)
guess_type(c("a.md", "b.R"))
# override the standard MIME table (tex is text/x-tex by default)
guess_type("tex", mime_extra = c(tex = "text/plain"))
# unknown extension 'bar'
guess_type("foo.bar")
# force unknown types to be plain text
guess_type("foo.bar", unknown = "text/plain")
# empty file extension
guess_type("Makefile")
# we know it is a plain text file
guess_type("Makefile", empty = "text/plain")
# subtypes
guess_type(c("abc.html", "def.htm"), subtype = c("charset=UTF-8", ""))
|
[1] "text/html"
[2] "application/pdf"
[3] "application/vnd.oasis.opendocument.text"
[4] "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
[5] "text/plain"
[1] "application/octet-stream" "application/octet-stream"
[1] "text/x-markdown" "text/plain"
[1] "text/plain"
[1] "application/octet-stream"
[1] "text/plain"
[1] "text/plain"
[1] "text/plain"
[1] "text/html; charset=UTF-8" "text/html"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.