You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署含fileInput的Shiny应用遇上传失败问题求助

Troubleshooting Shiny App File Upload Failure on shinyapps.io

Let’s walk through the most likely fixes for your LinkedIn-focused HTML parser app—since it works locally but fails silently on shinyapps.io, the issue is almost always tied to environment differences or overlooked deployment details:

1. Fix Path & File Handling

Local machines let you read/write files freely, but shinyapps.io runs in a restricted container. Make sure you’re using Shiny’s built-in temporary file paths instead of hardcoded local paths. For example:

output$parsed_data <- renderTable({
  uploaded_file <- input$html_upload
  if (is.null(uploaded_file)) return(NULL)
  
  # Use the temp path Shiny provides, not a local folder
  raw_html <- readLines(uploaded_file$datapath)
  # Your LinkedIn parsing logic here (rvest/xml2 calls)
})

Avoid writing files to arbitrary directories—shinyapps.io only allows writes to the app’s temp directory or the www folder (with strict limits).

2. Validate Dependencies Are Fully Declared

Even if your app runs locally, shinyapps.io might be missing packages or using incompatible versions. Double-check:

  • All required libraries (like rvest, xml2, dplyr) are loaded with explicit library() calls in your app.R/server.R files.
  • Use renv to lock in exact package versions:
    1. Run renv::init() locally to generate a lockfile
    2. Include the renv folder and renv.lock when deploying to shinyapps.io

This ensures the server uses the same package versions that worked for your local tests.

3. Dig Into Server Logs for Hidden Errors

Since you don’t get browser feedback, check the shinyapps.io logs for clues:

  • Go to your app’s dashboard on shinyapps.io
  • Click "Logs" in the sidebar
  • Look for errors like:
    • Failed package loading
    • Encoding issues when reading HTML files
    • Missing system libraries (e.g., libxml2 for HTML parsing)

If encoding is the problem, explicitly set it in readLines():

raw_html <- readLines(uploaded_file$datapath, encoding = "UTF-8")

4. Adjust File Upload Limits & Filters

shinyapps.io has a default 10MB upload limit—if your HTML files are larger, the upload will fail silently. Bump this limit by adding to the top of app.R:

options(shiny.maxRequestSize = 30*1024^2) # Sets limit to 30MB

Also, restrict your file input to only accept HTML files to avoid invalid uploads breaking parsing:

fileInput("html_upload", "Upload LinkedIn HTML File", accept = ".html")

5. Test for Local Environment Quirks

Sometimes local configurations (like custom .Rprofile settings, proxy rules, or system-level libraries) make the app work locally but fail on the server. Test your app in a clean R session (no custom profiles) to rule out these edge cases.


内容的提问来源于stack exchange,提问作者Gautam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:38:18