EVOLUTION-MANAGER
Edit File: downloadHandler.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: File Downloads</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for downloadHandler {shiny}"><tr><td>downloadHandler {shiny}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>File Downloads</h2> <h3>Description</h3> <p>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 <code>output</code> in your server function, and in the UI use <code><a href="downloadButton.html">downloadButton()</a></code> or <code><a href="downloadButton.html">downloadLink()</a></code> to make the download available. </p> <h3>Usage</h3> <pre> downloadHandler(filename, content, contentType = NA, outputArgs = list()) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>filename</code></td> <td> <p>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.)</p> </td></tr> <tr valign="top"><td><code>content</code></td> <td> <p>A function that takes a single argument <code>file</code> 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.)</p> </td></tr> <tr valign="top"><td><code>contentType</code></td> <td> <p>A string of the download's <a href="http://en.wikipedia.org/wiki/Internet_media_type">content type</a>, for example <code>"text/csv"</code> or <code>"image/png"</code>. If <code>NULL</code> or <code>NA</code>, the content type will be guessed based on the filename extension, or <code>application/octet-stream</code> if the extension is unknown.</p> </td></tr> <tr valign="top"><td><code>outputArgs</code></td> <td> <p>A list of arguments to be passed through to the implicit call to <code><a href="downloadButton.html">downloadButton()</a></code> when <code>downloadHandler</code> is used in an interactive R Markdown document.</p> </td></tr> </table> <h3>Examples</h3> <pre> ## Only run examples in interactive R sessions if (interactive()) { ui <- fluidPage( downloadButton("downloadData", "Download") ) server <- function(input, output) { # Our dataset data <- mtcars output$downloadData <- downloadHandler( filename = function() { paste("data-", Sys.Date(), ".csv", sep="") }, content = function(file) { write.csv(data, file) } ) } shinyApp(ui, server) } </pre> <hr /><div style="text-align: center;">[Package <em>shiny</em> version 1.5.0 <a href="00Index.html">Index</a>]</div> </body></html>