title: How to make Shiny redirect immediately?
body: <p>I set up a shiny app that checks for a GET string and presents a link if a file matching the <code>id</code> argument exists. Now what I would like to do is have the page redirect straight to the download file if a valid query is detected in the URL. Does anybody know of the syntax to insert, e.g. a <code>&lt;meta http-equiv=...&gt;</code> header from server.R?</p>
  
  <p>Motivation: I want to be able to download files directly into an R console session from a URL pointing at a Shiny app. So, a non-geeky user specifies their preliminary statistical model using Shiny, then a statistician downloads it into their usual working environment and takes it the rest of the way. I need to do this server-side rather than with something like javascript's <code>window.location</code> because javascript won't be supported client-side. </p>
  
  <p>Here is the server.R</p>
  
  <pre><code>shinyServer(function(input, output, clientData) {
    query &lt;- reactive(parseQueryString(clientData$url_search));
    revals &lt;- reactiveValues();
  
    ## obtain ID from GET string 
    observe({revals$id &lt;- query()$id}); 
  
    ## alternatively obtain ID from user input if any
    observe({input$submitid; if(length(id&lt;-isolate(input$manualid))&gt;0) revals$id &lt;- id;}); 
  
    ## update filename, path, and existance flag
    observe({ revals$filename &lt;- filename &lt;- paste0(id&lt;-revals$id,".rdata");
      revals$filepath &lt;- filepath &lt;- paste0("backups/",filename);
      revals$filexists &lt;- file.exists(filepath)&amp;&amp;length(id)&gt;0; });
  
    ## update download handler
    output$download &lt;- {downloadHandler(filename=function() revals$filename, content=function(oo) if(revals$filexists) system(sprintf('cp %s %s',revals$filepath,oo)))};
  
    ## render the download link (or message, or lack thereof)
    output$link &lt;- renderUI({
      cat('writing link widget\n');
      id&lt;-revals$id;
      if(length(id)==0) return(div(""));
      if(revals$filexists) list(span('Session download link:'),downloadLink('download',id)) else {
        span(paste0("File for id ",id," not found"));}});
  });
  </code></pre>
  
  <p>Here is the ui.R</p>
  
  <pre><code>shinyUI(pageWithSidebar(
            headerPanel(div("Banner Text"),"Page Name"),
            sidebarPanel(),
            mainPanel(
              htmlOutput('link'),br(),br(),
              span(textInput('manualid','Please type in the ID of the session you wish to retrieve:'),actionButton('submitid','Retrieve')))));
  </code></pre>
  
  <hr>
  
  <p>Update:</p>
  
  <p>In trying @jeff-allen 's suggestion, I ran into another problem: how to extract the filesystem path to which the files get copied for downloading <em>and</em> turn it into a valid URL? It's probably possible by screwing with shell scripts and http config settings on my local host, but how to do this in a portable way that doesn't require superuser privileges and is as shiny-native as possible?</p>