如何解决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 文件?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。