rdrop2无法在EC2服务器上运行,但仍可以在localhost和Shinyapps.io

问题描述

我正在制作一个闪亮的应用程序,该应用程序应该从DropBox下载.html文件,并通过htmlOutput()在该闪亮的应用程序中显示它。此外,我让它在AWS EC2 t2.micro实例上运行(所有基于this article的闪亮服务器配置)。问题是我的应用程序可以在localhost,Shinyapps.io上运行;但是,它不适用于我的EC2实例。该应用程序在Shiny Server上运行(在EC2实例内部)。

这是源代码 app.R ):

library(shiny)
library(rdrop2)
library(httr)

# token <- drop_auth()
# saveRDS(token,"droptoken.rds")
# Upload droptoken to your server
# ******** WARNING ********
# Losing this file will give anyone 
# complete control of your DropBox account
# You can then revoke the rdrop2 app from your
# dropBox account and start over.
# ******** WARNING ********
# read it back with readRDS
token <- readRDS("droptoken.rds")
# Then pass the token to each drop_ function
drop_acc(dtoken = token)

ui <- fluidPage(
  h1("rdrop2 practice"),htmlOutput("viewFile")
)

server <- shinyServer(function(input,output,session) {

  directoryPath <- paste0("path1/","path2/")
  
  fileName <- "file.html"
  
  filePath <- paste0(directoryPath,fileName)

  # Download File
  filePut <-
    try({
      withProgress(message = "Generating File",detail = "This may take few seconds depending of your Internet connection",drop_download(path = filePath,local_path = "./www",overwrite = TRUE,dtoken = token)
      )
      
      fileName
    },silent = TRUE)

  # Show File
  output$viewFile <- renderUI({
    
    validate(
      need(filePut,'File Not Available')
    )
    
    tags$div(class="resp-container")
    
    tags$iframe(class="resp-iframe",seamless = "seamless",src = filePut)
  })
})


shinyApp(ui,server)

当应用程序在localhost或shinyapps.io上运行时,该应用程序将执行适当的操作并在htmlOutput('viewFile')显示html文件。同时,它不适用于EC2实例。我在互联网上搜索了一些解决方案,但没有任何尝试。

如果有人对导致此行为的原因有所了解,我将不胜感激!

注意:我注意到我的EC2实例在应用运行时不发送XHR请求(与Shinyapps.io不同)

预期的行为

我的闪亮应用程序(使用rdrop2)应该在我的保管箱帐户中找到一个.html文件,进行下载,然后能够使用htmlOutput()进行显示

实际行为

找不到文件,它在try()文件不可用”上显示错误

帐户类型

DropBox基本版

解决方法

我碰巧找到了解决我问题的方法。这完全是 www 文件夹的 chmod(ing)问题。这样,闪亮的用户就可以访问我的 .html 文件?