0

I made a relatively elaborate Shiny app for my job that runs great locally. However, I am trying to host the app so that users who don't have R Studio downloaded can access it. I cannot get the app to run through shinyapps.io. It seems this is mostly related to the fact that it cannot find the files that are located on Dropbox. The app is based almost entirely on loading and writing files on Dropbox. I tried to change the file paths and use rdrop2 to load the files, but it changes the formatting of some things and would be pretty complicated to reconcile as far as I can tell. I'm very much a novice programmer and the thought of having to restructure the entire app is giving me a bit of anxiety and will certainly require a fair amount of effort. Does anyone know of a more "simple" way to modify files located on Dropbox through a shiny app hosted on shinyapps.io, preferably while still able to use the "openxlsx" package? Thank you very much in advance.

One workaround I thought might work but didn't was to make the file path to the Dropbox file specific to the user because anyone using the app should have access to Dropbox:

this.data <- as.data.frame(read.xlsx(paste("C:\Users\", Sys.info()[["user"]], "\Dropbox\rest of the file path", sep = "")))

reidj
  • 310
  • 1
  • 11
  • 1
    If it's public (open) data you might consider using an open data platform – HubertL Dec 04 '20 at 22:43
  • @HubertL that may be a possibility. Do you mean transferring my own data to an open platform? Do you recommend any specific platforms? Thanks. – reidj Dec 04 '20 at 22:52
  • [Google](https://www.google.com/publicdata), [AWS](https://registry.opendata.aws), [GitHub](https://github.com)... – HubertL Dec 04 '20 at 23:02
  • @HubertL Thanks for your suggestions. Unfortunately, the data contains names and phone numbers so I may only explore this as a last resort. – reidj Dec 04 '20 at 23:10
  • If you display publicly on shinyapps.io... – HubertL Dec 04 '20 at 23:12
  • @HubertL that’s a good point. I suppose I considered the app semi-private since not everyone would know how to access it. – reidj Dec 04 '20 at 23:16
  • same for github or google or aws as it will be in the middle of lots of other datasets. But semi-private is not private. I would recommend private hosting of app and data. – HubertL Dec 05 '20 at 01:19

1 Answers1

1

Disclaimer : I would not recommend relying on google-unsubmmitted URLs to guarantee privacy.

Modify the share link copied from DropBox replacing dl=0 by dl=1 to make the download start rather than display in DropBox UI.

You can then download.file() into a tempfile() before read.xlsx() it:

library(shiny)
library(openxlsx)
library(DT)

ui <- fluidPage(
  titlePanel("XL Read from dropbox"),
  mainPanel( DTOutput("dt"))
)

server <- function(input, output) {
  tmpfile <- tempfile(fileext='.xlsx')
  download.file(url = "https://www.dropbox.com/s/1v0l...5u803a9hg/my_file.xlsx?dl=1", destfile = tmpfile , mode="wb")
  output$dt <- renderDT(read.xlsx(outfile))
}

shinyApp(ui = ui, server = server)
HubertL
  • 19,246
  • 3
  • 32
  • 51