I am Developing REST API
using Plumber in R. In which I have a module where I was support to upload multiple CEL file and runs the algorithms, get the output and show it in the front-end.
I had refer this code but I am confused Is this code is correct or not.
plumber_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
}
start_plumber_api.R
plumber::plumb("C:/wamp64/www/testing/upload.R")$run(port = 1234)
HTML
<form action="http://127.0.0.1:1234/uploadfile" method="POST" enctype="multipart/form-data">
<label>Upload CEL File</label><br>
<input type="file" id="files" accept=".CEL, .gz" multiple />
<input type="submit" value="upload">
</form>
Getting this Error
Warning in Rook::Multipart$parse(req) : bad content body
Can anyone tell me Is this code is correct to upload CEL file or not and also Can anyone please explain me what does the error what does it indicates???????
Please HELP!
Thank You In Advance