I'm having problems understanding what I'm doing wrong when serializing a report using plumber
#* produce the report
#* @param userID:str userID
#* @param title:str title of repot
#* @param taskId:str id of the task
#* @param alpha:double confidence interval for plots
#* @serializer contentType list(type = "application/pdf")
#* @get /pdf
function(userID = "realUser1",
title = "Draft Report task1",
taskId = "realRask1",
alpha = 0.1){
tmp <- tempfile()
name = paste0(tmp,'.pdf')
res$setHeader("Content-Disposition", paste0("attachment; filename=", basename(name)))
rmarkdown::render(input = "~/BiologyAPP/BiologyAPI/BiologicalDataAPI/reports/testReport.Rmd",
output_file= tmp,
params = list(author= userID,
title= title,
date= Sys.Date(),
taskId= taskId,
alpha= alpha))
on.exit({file.remove(name)}, add = TRUE)
readBin(name, "raw", n=file.info(name)$size)
}
for some reason I can't run the code if I use the tag serializer. it returns:
"Running plumber API at http://127.0.0.1:9064
Error in nchar(ctype) :
cannot coerce type 'closure' to vector of type 'character'"
but the same error disappears if I remove the tag, of course that then I've problems on the other end for deserializing an unknown file