【发布时间】:2015-10-26 12:06:32
【问题描述】:
我正在开发一个闪亮的应用程序,当 UI 中提供了 url 时,我需要从 web 获取和下载文件。
在服务器站点上,当我尝试获取文件并将其下载到特定位置时,应用程序出现错误。我猜是因为反应程序。
下面提供了一个示例代码,请让我知道我哪里错了。
服务器端: {
library(shiny)
require(XML)
require(utils)
shinyServer(function(input, output, session) {
dfile <- "~/dest/temp.pdf"
dest <- "~/dest"
url<-input$pdfurl
download.file(url,dfile)
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)
lapply(myfiles, function(i) system(paste('"D:/pranav/software/xpdf/bin64/pdftotext.exe"', paste0('"', i, '"')), wait = FALSE) )
}
客户端:
{
library(shiny)
row <- function(...) {
tags$div(class="row", ...)
}
col <- function(width, ...) {
tags$div(class=paste0("span", width), ...)
}
shinyUI(fluidPage(
fluidRow(
column(12,style = "background-color:#ADD8C9;",
titlePanel("Document Reader"),
fluidRow(
column(8,style = "background-color:#ADD8C6;",
tags$div(
class = "container",
row(
col(3, textInput("pdfurl", "PDF URL"))
),
row(
col(6, style = "width:600px;",htmlOutput('pdfviewer'))
)
)
),
column(4,style = "background-color:#ADD8C9;",
)
)
)
)
)
)
}
【问题讨论】:
标签: r web-applications shiny reactive-programming