我想与 RestRServe 合作,上传一个 .xlsx 文件进行处理。我已经成功地使用 .csv 尝试了以下操作,但是使用 get_file 对 .xlsx 进行了一些细微的修改并没有取得成果。
ps <- r_bg(function(){
library(RestRserve)
library(readr)
library(xlsx)
app = Application$new(content_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
app$add_post(
path = "/echo",
FUN = function(request, response) {
cnt <- request$get_file("xls")
dt <- xlsx::read.xlsx(cnt, sheetIndex = 1, header = TRUE)
response$set_body("some function")
}
)
backend = BackendRserve$new()
backend$start(app, http_port = 65080)
})