streamdal/plumber

Help understanding problem rendering pdf with plumber

HPicatto opened this issue · 2 comments

Hello, I posted a problem that I'm having 10 days ago on the Rstudio community but I didn't get any help. https://community.rstudio.com/t/help-understanding-problem-rendering-pdf-with-plumber/134266?u=hpicatto

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

Hi @HPicatto,
This repo is for batch.sh's message bus tool also called Plumber. I believe you want to submit your issue to https://github.com/rstudio/plumber instead

You are right, I'm quite embarrassed. sorry for wasting your time