rstudio / plumber

Turn your R code into a web API.
https://www.rplumber.io
Other
1.4k stars 257 forks source link

Multi file upload #579

Open ThHarbig opened 4 years ago

ThHarbig commented 4 years ago

I'm using the development version of plumber due to the newly implemented multipart/form-data file upload. I'd like to be able to send an arbitrary number of files to the server. As a workaround I'm sending the files separately and save them in a global variable. However, I think this feature might still be valuable to some users.

meztez commented 4 years ago

See #575,

Do you use swagger UI or you do it directly through a CURL command?

ThHarbig commented 4 years ago

I'm using javascript axios (but I also tried it via the swagger UI)

meztez commented 4 years ago

if you define your endpoint as

#* @post /endpoint
function(...) {
  files <- list(...)
  files <- files[!names(files) %in% c("req", "res")]
  #list of files in the form list(nm = rawbytes, nm = rawbytes, ...)
}

It should work for now (not in swagger) until we come up with a better solutions.

meztez commented 4 years ago

Swagger has been updated. This should work.

#* @param f:[file]
#* @post /upload
function(f) {
  names(f)
}

Closable