tests/testthat/test-upload-file.R

test_that("can upload with redirect", {
  skip_on_cran()

  str <- paste(letters, collapse = '')
  tmp <- tempfile()
  writeBin(str, tmp)

  resp <- PUT(
    "https://hb.cran.dev/redirect-to?url=/put&status_code=307",
    body = upload_file(tmp)
  )

  expect_equal(resp$status_code, 200)
  expect_equal(resp$url, "https://hb.cran.dev/put")
  json <- content(resp)
  expect_equal(json$data, str)
})

Try the httr package in your browser

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

httr documentation built on Aug. 15, 2023, 9:08 a.m.