想把xlsx文件直接上传到服务器shinyserver,在根据需要读取其中表格,但是
input默认只能读取csv,然后通过write.csv写到服务器本地文件,因此我用了file.copy 方法直接拷,本机上传下载一切正常。虽然上传可以完成,但是会有warning,此warning可能就是部署后上传功能不能实现的原因,请求大神帮忙看下为什么,怎么解决。
部署后可访问的网站:
https://jeremy-party.shinyapps.io/estudia/(下载功能正常,上传zhong'daun)
Listening on http://127.0.0.1:4047
Warning in file.copy(input$file1, "./") :
拷贝.\0.xlsx到.\0.xlsx时出了问题:No such file or directory
Warning in file.copy(input$file1, "./") :
拷贝.\21740到.\21740时出了问题:No such file or directory
Warning in file.copy(input$file1, "./") :
拷贝application\vnd.openxmlformats-officedocument.spreadsheetml.sheet到.\vnd.openxmlformats-officedocument.spreadsheetml.sheet时出了问题:No such file or directory
library(shiny)
server <- function(input , output){
observe({
if (is.null(input$file1)) return()
file.copy(input$file1,"./")
file.rename("0.xlsx","EstudiaSpa.xlsx")
})
output$Download <- downloadHandler(
filename <- function() {
"estudia.xlsx"
},
content <- function(file) {
file.copy("EstudiaSpa.xlsx",file)
}
)
}
ui <- fluidPage(
fluidRow(
tags$div(
column(5,fileInput("file1", "Choose The File",
accept = NULL
)),
column(6,downloadButton('Download', 'Descargar',style = "margin-top:25px")))
,style = "position: absolute;left: 50%; top: 50%;transform: translate(-50%,-50%);")
)