我试图通过R水管工的HTTP请求访问PDF,用tabulizer包读取它,并以JSON格式响应PDF。我正透过邮递员将一份53 am的PDF投寄至我的路线,并收到以下错误:
normalizePath中的错误(path.expand(路径),winslash,mustWork)。
我的R路由代码如下:
#' @post /tab
#' @json
function(req){
library("tabulizer")
f <- req$postBody
extract_tables(f)
}当我将extract_tables()函数与的本地路径一起使用时,它作为一个get路由非常有效。
#' @get /tab
#' @json
function(){
library("tabulizer")
f <- "C:/Users/kelse/Desktop/Rscripts/Tessaract/table.pdf"
extract_tables(f)
}有没有人知道如何通过水管工发布pdf文件并在一个函数中访问它?
发布于 2019-08-07 18:05:10
您可以尝试使用@序列化程序通过HTTP发布
#* @serializer contentType list(type="application/pdf")
#* @get /pdf
function(){
tmp <- tempfile()
pdf(tmp)
plot(1:10, type="b")
text(4, 8, "PDF from plumber!")
text(6, 2, paste("The time is", Sys.time()))
dev.off()
readBin(tmp, "raw", n=file.info(tmp)$size)
}https://stackoverflow.com/questions/52786869
复制相似问题