Вы можете использовать plumber
и Rook
для загрузки файлов с помощью POST.
Вот небольшой пример
api.R
library(plumber)
library(Rook)
#* Upload file
#* @param upload File to upload
#* @post /uploadfile
function(req, res){
fileInfo <- list(formContents = Rook::Multipart$parse(req))
## The file is downloaded in a temporary folder
tmpfile <- fileInfo$formContents$upload$tempfile
## Copy the file to a new folder, with its original name
fn <- file.path('~/Downloads', fileInfo$formContents$upload$filename)
file.copy(tmpfile, fn)
## Send a message with the location of the file
res$body <- paste0("Your file is now stored in ", fn, "\n")
res
}
Запустить сервер
plumber::plumb('api.R')$run(port = 1234)
Отправить файл test.txt с помощью curl
curl -v -F upload=@test.txt http://localhost:1234/uploadfile