I tested to attach an STL file as body on a POST request. Configuration: Windows 10, Postman (POST->binary), R 3.4.2. The R code for the POST request looks like:
#' @post /endpointname
function(req) {
rawstl = req$postBody # STL file is attached as Binary in Postman.
rawData1 = as.raw(unlist(lapply(rawstl, charToRaw)))
## E.g. 43 4f 4c 4f 52 3d ...
...
}
The output of this is the same as a direct binary read on the STL file using:
con = file(fileName, "rb")
rawData2 = readBin(con, "raw", n=100, size=1, endian="little")
however there are some parts missing if the Plumber version (above) is used. I think the reason could be the way line endings are handled or introduced, or Plumber's default filters.
The missing values occur between the elements of req$postBody: e.g. while rawData2
holds [a, b, c, d, e, f, g], rawData1
holds [a, b, e, f]. The R object rawstl
in the function above has length > 1 and the missing values occur between the sub-lists there.
I played around for some time but I cannot figure out what is broken.