weixin_41733172 2020-03-19 13:47 采纳率: 0%
浏览 328

Shinyapp利用file.copy上传xlsx到shinyserver 报错,本地调试正常。但点上传会引起warning,部署服务器后上传功能中断可能是warning引起的,以下是可重现代码,请求帮助。

想把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%);")

  )
  • 写回答

1条回答 默认 最新

  • 清风徐阿莱 2020-05-06 09:43
    关注

    感谢你让我找到直接保存文件到服务器的方法file.copy()

    你这个的问题是,input$file 改成 input$file$datapath

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题