diff --git a/R/upload.R b/R/upload.R index de7b23bd..b6f1b402 100644 --- a/R/upload.R +++ b/R/upload.R @@ -38,6 +38,8 @@ curl_upload <- function(file, url, verbose = TRUE, reuse = TRUE, ...) { } } return(buf) + }, seekfunction = function(offset){ + seek(con, where = offset) }, forbid_reuse = !isTRUE(reuse), verbose = verbose, ...) if(!is.na(infilesize)){ handle_setopt(h, infilesize_large = infilesize) diff --git a/tests/testthat/test-seek.R b/tests/testthat/test-seek.R new file mode 100644 index 00000000..2b72a3c8 --- /dev/null +++ b/tests/testthat/test-seek.R @@ -0,0 +1,15 @@ +context("Seek") + +test_that("Seeking works after redirect",{ + skip_on_cran() + str <- paste(letters, collapse = '') + tmp <- tempfile() + writeBin(str, tmp) + url <- httpbin('/redirect-to?url=/put&status_code=307') + req <- curl::curl_upload(tmp, url, verbose = FALSE) + headers <- curl::parse_headers(req$headers, multiple = TRUE) + expect_length(headers, 2) + expect_equal(req$status_code, 200) + content <- jsonlite::fromJSON(rawToChar(req$content))$data + expect_equal(content, str) +})