I'm using the download handler with a GET using httr package, which sends an XLSX file. The code i have below works, but the question i have is there a way to check if that file any exists/return from the GET prior to sending a generated file out? Right now, if the file doesn't exist, the code still creates a blank file (which I'd like to avoid).
download_link_file <- reactive({
url <- paste0(EXPORT_DOWNLOAD_URL, '-', values$SOME_ID)
url
})
output$downloadDataLink <- downloadHandler(
filename = function() {
paste("file-export", "-", Sys.Date(), ".xlsx", sep="")
},
content = function(file) {
GET(download_link_file(), write_disk(file))
},
contentType = "excel"
)