This is a helper to determine which MIME type should be used for a file. Three types of input are acceptable:

  • Native Google Drive file types. Important examples:

    • "document" for Google Docs

    • "folder" for folders

    • "presentation" for Google Slides

    • "spreadsheet" for Google Sheets

  • File extensions, such as "pdf", "csv", etc.

  • MIME types accepted by Google Drive (these are simply passed through).

drive_mime_type(type = NULL)

Arguments

type

Character. Google Drive file type, file extension, or MIME type. Pass the sentinel expose() if you want to get the full table used for validation and lookup, i.e. all MIME types known to be relevant to the Drive API.

Value

Character. MIME type.

Examples

## get the mime type for Google Spreadsheets drive_mime_type("spreadsheet")
#> [1] "application/vnd.google-apps.spreadsheet"
## get the mime type for jpegs drive_mime_type("jpeg")
#> [1] "image/jpeg"
## it's vectorized drive_mime_type(c("presentation", "pdf", "image/gif"))
#> [1] "application/vnd.google-apps.presentation" #> [2] "application/pdf" #> [3] "image/gif"
## see the internal tibble of MIME types known to the Drive API drive_mime_type(expose())
#> # A tibble: 77 x 4 #> mime_type ext human_type default #> <chr> <chr> <chr> <lgl> #> 1 application/x-vnd.oasis.opendocument.presentation <NA> <NA> NA #> 2 text/tab-separated-values tsv tsv TRUE #> 3 image/jpeg jpeg jpeg TRUE #> 4 image/jpeg jpg jpg FALSE #> 5 image/jpeg jpe jpe FALSE #> 6 image/bmp <NA> <NA> NA #> 7 image/gif gif gif TRUE #> 8 application/vnd.ms-excel.sheet.macroenabled.12 <NA> <NA> NA #> 9 application/vnd.openxmlformats-officedocument.word… dotx dotx TRUE #> 10 application/vnd.ms-powerpoint.presentation.macroen… <NA> <NA> NA #> # ... with 67 more rows