R/bin-qr-code.R

Defines functions bin_qr_code

Documented in bin_qr_code

#' Get QR code for bin on Filebin
#'
#' @inheritParams file_post
#' @inheritParams bin_archive
#'
#' @return File name of the archive.
#' @export
#'
#' @examples
#' \dontrun{
#' posted <- file_post(LOREM_IPSUM, bin = "latin-text")
#' bin_qr_code("latin-text", file = tempfile(fileext = ".png"))
#' }
bin_qr_code <- function(bin, file = NA) {
  url <- file.path(base_url(), "qr", bin)

  response <- GET(url)

  if (is.na(file)) {
    file <- paste0(bin, ".png")                                 # nocov
  }

  writeBin(content(response, as = "raw"), file)

  file
}

Try the filebin package in your browser

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

filebin documentation built on Sept. 2, 2023, 9:07 a.m.