R/getMimeType.R

Defines functions getMimeType

getMimeType <- function(filename) {
  assertthat::assert_that(is.character(filename))

  allowedFiles <- c(".png", ".tif", ".jpeg", ".jpg", ".pdf", ".kml")

  assertthat::assert_that(!all(!endsWith(filename, allowedFiles)))
  if (endsWith(filename, ".png")) {
    return("image/png")
  } else if (endsWith(filename, ".tif")) {
    return("image/tiff")
  } else if (endsWith(filename, ".jpeg") || endsWith(filename, ".jpg")) {
    return("image/jpeg")
  } else if (endsWith(filename, ".pdf")) {
    return("application/pdf")
  } else if (endsWith(filename, ".kml")) {
    return("application/vnd.google-earth.kml+xml")
  }
}

Try the cmsafvis package in your browser

Any scripts or data that you put into this service are public.

cmsafvis documentation built on Sept. 15, 2023, 5:15 p.m.