title: R Shiny automatically start download
body: <p>I want to initialize the download of a file in R Shiny when a button is pressed and do some checks before generating the file.</p>
  
  <p>I've fooled arround with the downloadHandler (<a href="https://shiny.rstudio.com/gallery/file-download.html" rel="nofollow noreferrer">https://shiny.rstudio.com/gallery/file-download.html</a>). But I want to catch the event of another button, do some things and checks with the data and when everything went well generate the file and initialize the download without having to press the download button from downloadHandler. </p>
  
  <p>I've implemented most checks for now in the downloadHandler, but it now generates a failed download when some checks aren't fulfilled. I don't like the behavior.</p>
  
  <pre><code>output$downloadData &lt;- downloadHandler(
    filename = function() { paste("DATA_EXPORT-", Sys.Date(), ".csv", sep="") 
  },
    content = function(file) {
      withProgress(message = 'Export data', value = 0, {
      # Number of steps
      n &lt;- 3
  
      incProgress(1/n, detail = "Pre checks and get data")
  
      # checks if inputs for get_data are well defined
  
      dataSet &lt;- get_data(blabla)
  
      incProgress(1/n, detail = "Post Proces and check")
  
  
  
      incProgress(1/n, detail = "generate flatfile")
      write.csv(dataSet, file, row.names = FALSE)
  
      })
  
    }
  )
  </code></pre>