Parametized Rmarkdown with fileinput on Rstudio Connect New

Hi,

I create a new issue to link to an old question like suggest @cole.(Parametized Rmarkdown with fileinput on Rstudio Connect)

My problem is the same, I can't upload a file (csv) to be read on Rstudio Connect. My Error:

Error: '/opt/rstudio-connect/mnt/tmp/RtmpjYLtid/file2a54717ab74/0.csv' does not exist.

When I use params$data$datapath, I have this error:

Error in params$data$datapath : $ operator is invalid for atomic vectors

Note that my reprex works on Rstudio Server Pro but not on Rstudio Connect.

---
title: "Read upload file on Rstudio Connect"
output: html_document
params:
  data:
    label: "Csv Files"
    value: "cars.csv"
    input: file
---

readr::read_csv(params$data)

I use Rstudio Connect v1.7.6-6 and R 3.5.1.

Any help would be highly appreciated.

Rodrigue

Hi @Rodrigue

Thanks for opening this!! We had another customer raise this issue somewhat recently as well. It is unclear that this should ever have worked, since the place that this file is written to is destroyed almost immediately. It may have been a change to Connect's execution environment that enforces the "quickness" for the destruction since that last thread, though.

We are tracking internally a way to support this functionality better, and will definitely add your vote!

A few possible workarounds in the short term are below. Would any of these work within your organization?

  • Have a location where users can upload files that makes these files accessible over a file share or URL. In the parameterized R Markdown report, instead of a fileInput widget, the user can enter the URL or path to the file (in a textInput). Access control for these URLs / file paths and segregating the data by user may be a bit challenging, if that is important to your use case. However, you could always "secure" this data through obscurity using a UUID, for instance.

  • The problem you are experiencing will not affect fileInput widgets in a Shiny application. As a result, you can also build a simple Shiny application that accepts a fileInput widget and then generates output or runs an R Markdown report. This unfortunately does not utilize Connect's scheduling / managing / output storing functionality for Parameterized R Markdown documents.

  • In the newest version of Connect, you can even use a pin, described here: https://blog.rstudio.com/2019/09/23/rstudio-connect-1-7-8-put-a-pin-in-it/

As an example of what a combination might look like, I could create a Shiny application or Plumber API that allows users to "upload" data and then hosts it somewhere that it is accessible either on the filesystem or over a REST API (Plumber, pin, etc.). That file path / URL could then be copied into a textInput in the R Markdown report and the code can pick up the data from that path. Another workaround would be to create a file share that they can move files to which is accessible to their desktops and to the RStudio Connect server and files can be sourced from that location.

I'd love to have a working example of an easy way to make this pattern work, since Connect's fileInput widget is not functional today.

Thanks Cole for your answer. You confirm that there are a bug with parametized report. Thanks.

The use of shiny instead works for me.

We didn't yet install the last version of Rstudio Connect. I'll try pin asap.

Thanks,

Rodrigue

1 Like