如何在 plumber api 中上传 xlsx 文件作为输入
how to upload a xlsx file in plumber api as a input
I want an api which can upload a xlsx file,which select by the
user.The api should take any xlsx file as a input.
#* @post /upload_excel
#* @param f:file
#* @param sheet:str
#* @param range:str
function(f, sheet, range) {
tmp <- tempfile("plumb", fileext = paste0("_", basename(names(f))))
on.exit(unlink(tmp))
writeBin(f[[1]], tmp)
t <- readxl::read_excel(tmp, sheet, range)
nrow(t)
}
I want an api which can upload a xlsx file,which select by the user.The api should take any xlsx file as a input.
#* @post /upload_excel
#* @param f:file
#* @param sheet:str
#* @param range:str
function(f, sheet, range) {
tmp <- tempfile("plumb", fileext = paste0("_", basename(names(f))))
on.exit(unlink(tmp))
writeBin(f[[1]], tmp)
t <- readxl::read_excel(tmp, sheet, range)
nrow(t)
}