Search code examples
rshinyshiny-server

Failed to download data from FTP server to shiny app in shiny server


My shiny app needs to download file from ftp, I can download using R console. For example:

R console:

library(curl)

setwd("/srv/shiny-server/PowerSeq_app/www") curl_download("https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv",destfile="reviews2.csv")`

You can see the file is download in the directory:

enter image description here

However, when I deploy app using shiny server, the error occurs:

Shiny server:

Error in curl_download: Failed to open file /srv/shiny-server/PowerSeq_app/www/reviews2.csv.

I assumed this is file path issue, I also turned to this link, but I still cannot get it resolved. Many Thanks in advance.


Solution

  • Finally I realized it's user privilege issue, we have to change the privilege of user "shiny":

    groupadd shiny-apps
    usermod -aG shiny-apps shiny
    chown -R shiny:shiny-apps /srv/shiny-server
    chmod g+w /srv/shiny-server
    chmod g+s /srv/shiny-server
    

    enter image description here