I have an API function that takes an input, obtains necessary data using that input, calls a .rmd file, and using that .rmd file produces a pdf file in a specified directory. I need the remaining part of my API to take the newly produced pdf file and have it posted through HTTP. However, whenever I try to do that, I end up getting a corrupt file as an output.
This is my current code:
#* @serializer contentType list(type="application/pdf")
#* parameter_selection
#* @param a1
#* @get /pdf
function( a1) {
#Please assume that the filename location is correct.
filename = paste0( a1, '_','report','.pdf', sepp='')
locale_filename = paste0('notebooks/',filename, sepp= '')
readBin(locale_filename, "raw", n=file.info(locale_filename)$size)
}
Thank you.