【发布时间】:2015-10-19 22:47:51
【问题描述】:
我想在我闪亮的应用程序的www 文件夹中解压缩一个压缩的 .mdb 文件,在其中查询数据,然后将其删除。 Unzip() 在我的本地机器上工作,但是当我在 shinyapps.io 部署应用程序时,解压缩文件时出现问题。因为我无法 read.table() 生成的文件(它是一个 .mdb)我不认为 unz() 会工作。
此代码在我的本地机器上运行时有效
服务器:
require(shiny)
shinyServer(function(input, output) {
observeEvent(input$run,{ #Run Button
dbName=unzip('www/test.zip', list=T)
output$name=renderText({
paste(dbName[1])
})
db=unzip('www/ttt.zip', exdir='www', unzip=getOption("unzip"))
test1=read.csv(db) #.csv for simplicity, but my problem uses a .mdb
file.remove(db)
output$testcount=renderText({
paste(sum(test1))
})
})#/Run Button
})#/SS
用户界面:
shinyUI(
sidebarLayout(
sidebarPanel(width=3,
h5('ZIP test'),
p(align="left",
shiny::actionButton("run", label = "Run!")
),
textOutput(outputId = "name"),
textOutput(outputId = "testcount")
),
mainPanel(width=9,
plotOutput(outputId = "probs",height = "550px")
)
)
)
但上传到 Shinyapps.io 时失败。
知道我在这里做错了什么吗?我试过直接传递文件路径,并弄乱unzip= 选项,但无济于事。如果我删除第二个调用,它会告诉我名称就好了,但如果我尝试解压缩文件,它会中断。
感谢任何帮助!
编辑
我能够通过删除 exdir='www', unzip=getOption("unzip") 并在根目录中查找文件来使其工作:test1=read.csv('file1.csv')
【问题讨论】:
-
这对我有用,你能发布一些示例 zip 文件吗?
-
我从未使用过 shinyapps.io,但如果您有命令行访问权限,您可以尝试检查 zip 文件的文件权限(并使用 chmod 755 myzip.zip 更改它们)。我还必须从您的 unzip 调用中删除
unzip=getOption("unzip")部分,因为这会给出有关 Windows 特定选项的错误消息(如果 shinyapps 在 linux 上运行,请尝试删除它)。 -
感谢您的回复!通过删除您建议的代码并将其解压缩到根目录(如@Sebastian 所述),我能够使其工作。