downloadHandler

0th

Percentile

File Downloads

Allows content from the Shiny application to be made available to the user as file downloads (for example, downloading the currently visible data as a CSV file). Both filename and contents can be calculated dynamically at the time the user initiates the download. Assign the return value to a slot on output in your server function, and in the UI use downloadButton or downloadLink to make the download available.

Usage
downloadHandler(filename, content, contentType = NA)
Arguments
filename
A string of the filename, including extension, that the user's web browser should default to when downloading the file; or a function that returns such a string. (Reactive values and functions may be used from this function.)
content
A function that takes a single argument file that is a file path (string) of a nonexistent temp file, and writes the content to that file path. (Reactive values and functions may be used from this function.)
contentType
A string of the download's http://en.wikipedia.org/wiki/Internet_media_type{content type}, for example "text/csv" or "image/png". If NULL or NA, the content type will be guessed base
Aliases
  • downloadHandler
Examples
# In server.R:
output$downloadData <- downloadHandler(
  filename = function() {
    paste('data-', Sys.Date(), '.csv', sep='')
  },
  content = function(file) {
    write.csv(data, file)
  }
)

# In ui.R:
downloadLink('downloadData', 'Download')
Documentation reproduced from package shiny, version 0.9.0, License: GPL-3

Community examples

Looks like there are no examples yet.