Learn R Programming

wand (version 0.5.0)

get_content_type: Discover MIME type of a file based on contents

Description

There are a limited number of header "magic" bytes checked directly by this function but cover quite a bit of ground. After that, guess_content_type() is called which uses file extension-to-MIME mappings. File an issue or PR if more magic-byte-level comparisons are required/desired. If no match is found, ??? is returned.

Usage

get_content_type(path)

Arguments

path

path to a file

Value

character vector

Details

Initial in-R header mapping logic borrowed from MimeTypes.java from servoy-client

Examples

Run this code
# NOT RUN {
get_content_type(system.file("extdat", "test.pdf", package="wand"))
# }

Run the code above in your browser using DataLab