Giter Site home page Giter Site logo

shinyfiles's Introduction

shinyFiles

R-CMD-check CRAN_Release_Badge CRAN_Download_Badge

This package extends the functionality of shiny by providing an API for client side access to the server file system. As many shiny apps are run locally this is equivalent to accessing the filesystem of the users own computer, without the overhead of copying files to temporary locations that is tied to the use of fileInput().

The package can be installed from CRAN using install.packages('shinyFiles').

Usage

The package is designed to make it extremely easy to implement file system access. An example of implementing a file chooser would be:

In the ui.R file

shinyUI(bootstrapPage(
    shinyFilesButton('files', label='File select', title='Please select a file', multiple=FALSE)
))

In the server.R file

shinyServer(function(input, output) {
    shinyFileChoose(input, 'files', root=c(root='.'), filetypes=c('', 'txt'))
})

It is equally simple to implement directly in your custom html file as it only requires a single <button> element. The equivalent of the above in raw html would be:

<button id="files" type="button" class="shinyFiles btn" data-title="Please select a file" data-selecttype="single">
    File select
</button>

For an overview of all the different modules try the shinyFilesExample() function in the package. It gives an overview of all the necessary code, along with descriptions and working examples.

Credits

  • The file icons used in the file system navigator are taken from FatCows Farm-Fresh Web Icons (https://www.fatcow.com/free-icons)
  • RStudio is a trademark of RStudio, Inc. File icons used by permission of RStudio, Inc.

shinyfiles's People

Contributors

afriendlyrobot avatar bellma-lilly avatar daattali avatar elcombato avatar ifellows avatar josuat avatar keqiang avatar lanceupton avatar raggaraluz avatar rpodcast avatar sgvignali avatar thomasp85 avatar vnijs avatar zeehio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shinyfiles's Issues

Example in README.md returns error from root argument

When I try to run the example from the README, I get the following error..

Unhandled error in observer: Roots must be a named vector or a function returning one

I can run shinyFilesExample() without problem. Also, if I give a name to the root argument as in the example in inst..

shinyFileChoose(input, 'files', root=c("R Inst" = R.home()), session=session, restrictions=system.file(package='base'))

There isn't an error, but I can't see any files.

How can I add an icon to shinyFilesButton

Hello Thomas,
I wonder If how I can add an icon to shinyFiles button. Here I have an example:

image

Is it possible add a argument called 'icon' in shinyFiles( id,input, icon, ...)?

Thank so much in advance!

shinyFilesSelect does not display anything when called from modalDialog

I'm trying to embed the shinyFilesButton into a modal provided by shiny version 0.14, and it doesn't seem to work quite as intended. MRE below.

# devtools::install_github("thomasp85/shinyFiles")
library(shiny) # version 0.14
library(shinyFiles)

ui = fluidPage(
  pageWithSidebar(
    headerPanel("Selections with Modals and shinyFiles", "shinyFiles w Modals"),
    sidebarPanel(
      helpText("The button below is used to display a modal with options to upload a file."),
      actionButton("upload", "Upload a File")
    ),
    mainPanel(
      verbatimTextOutput("filepath")
    )
  )
)

server = function(input, output, session) {
  shinyFileChoose(input, "file", roots=c("Root"=path.expand("~")), session=session)

  output$filepaths = renderPrint({
    parseFilePaths(path.expand("~"), input$file)
  })

  observeEvent(input$upload, {
    form = modalDialog(
      h4("Click the button below to choose your file"),
      shinyFilesButton("file", "Browse", "Please Select a File...", multiple=F), 
      title="Upload a File", 
      footer=modalButton("Submit"), 
      easyClose=F)

    showModal(form)
  })
}

shinyApp(ui, server)

Session Info:

Session info -------------------------------------------------------------
 setting  value                       
 version  R version 3.3.1 (2016-06-21)
 system   x86_64, mingw32             
 ui       RStudio (0.99.902)          
 language (EN)                        
 collate  English_United States.1252  
 tz       America/New_York            
 date     2016-09-15                  

Packages -----------------------------------------------------------------
 package    * version date       source                               
 curl         1.2     2016-08-13 CRAN (R 3.3.1)                       
 devtools   * 1.12.0  2016-06-24 CRAN (R 3.3.1)                       
 digest       0.6.10  2016-08-02 CRAN (R 3.3.1)                       
 git2r        0.15.0  2016-05-11 CRAN (R 3.3.0)                       
 htmltools    0.3.5   2016-03-21 CRAN (R 3.3.1)                       
 httpuv       1.3.3   2015-08-04 CRAN (R 3.3.1)                       
 httr         1.2.1   2016-07-03 CRAN (R 3.3.1)                       
 jsonlite     1.0     2016-07-01 CRAN (R 3.3.1)                       
 memoise      1.0.0   2016-01-29 CRAN (R 3.3.1)                       
 mime         0.5     2016-07-07 CRAN (R 3.3.1)                       
 R6           2.1.3   2016-08-19 CRAN (R 3.3.1)                       
 Rcpp         0.12.7  2016-09-05 CRAN (R 3.3.1)                       
 RJSONIO      1.3-0   2014-07-28 CRAN (R 3.3.0)                       
 shiny      * 0.14    2016-09-10 CRAN (R 3.3.1)                       
 shinyFiles * 0.6.2   2016-09-15 Github (thomasp85/shinyFiles@e354fe5)
 withr        1.0.2   2016-06-20 CRAN (R 3.3.1)                       
 xtable       1.8-2   2016-02-05 CRAN (R 3.3.1)

Have MyDocuments and Desktop in getvolumes (with solution)

Right now to have MyDocuments and Desktop as volumes on Windows machines I am using this.

(Note that this depends on powershell being available)

  myVolumes <- function() {
    if (.Platform$OS.type == "windows") {
      extra_volumes <- c(Desktop = system2("powershell", "[Environment]::GetFolderPath('Desktop')", stdout = TRUE),
                         MyDocuments = system2("powershell", "[Environment]::GetFolderPath('MyDocuments')", stdout = TRUE),
                         UserProfile = system2("powershell", 'echo $env:USERPROFILE', stdout = TRUE))
    } else {
      extra_volumes <- c()
    }
    c(extra_volumes, shinyFiles::getVolumes()())
  }

And then

  shinyFileChoose(input, 'whatever', roots = mygetVolumes)

Maybe this would be a nice addition to getVolumes.

Currently getVolumes returns a function that is called very often, to see if there are updates on any volume (new USB attached, etc). This has a strong performance penalty on Windows.

To address the performance penalty it would be useful to have a refresh button next to the volume selection menu so getVolumes is only called every once in a while.

As a workaround, if you don't care about "new attached USB drives" you can use:

  list_of_volumes <- mygetVolumes()
  shinyFileChoose(input, 'whatever', roots = list_of_volumes)

OsX EI Capitan (10.11), unable to choose directory from user folder

Recently I found the shinyDirChoose function stopped working when I set the root to c(wd = "~") in mac. The "Select" button does not respond to clicking. Also folders in home folder cannot be expanded to view the subdirectories.

I read from the Latex updates that 'Under OS X 10.11, El Capitan, writing to /usr is no longer allowed, even with Administrator privileges'. I'm not sure if it's caused by the same issue or it's just my personal configuration issue.

Here's a minimal example.

server.R:

library(shiny)
library(shinyFiles)
shinyServer(function(input, output, session) {
    volumes <- getVolumes()
    shinyDirChoose(input, 'data_folder', roots=c(wd = '~'), session=session, restrictions=system.file(package='base'))
    output$directorypath <- renderPrint({parseDirPath(c(wd = '~'), input$data_folder)})
})

ui.R:

`
library(shiny)
library(shinyFiles)

shinyUI(bootstrapPage(
    shinyDirButton('data_folder', 'Select Data Folder', 'Please select a folder', FALSE),
    verbatimTextOutput('directorypath')
))

I would really appreciate if you could look into this. Thanks a lot!

small typo in usage example section

Hi Thomas,

thanks again for your package! Really great :-) Just a tiny remark, there is a typo in the Usage section of your page. In the code below mulitple should be read multiple. Otherwise the example doesn't render...

shinyUI(bootstrapPage(
shinyFilesButton('files', label='File select', title='Please select a file', mulitple=FALSE)
))

Should be:

shinyUI(bootstrapPage(
shinyFilesButton('files', label='File select', title='Please select a file', multiple=FALSE)
))

best Herman,
the Netherlands

Extra "/" when using parseSavePath

When using parseSavePath, the returned datapath value has 2 extra "/" added to it just after the roots, making the path to the file incorrect.

parseSavePath(roots = c(Computer = "~/"), input$my_save)

       name      type                   datapath
1 test3.rmd rmarkdown ~///Desktop/test/test3.rmd

shinyDirChoose() with getVolumes() only select C:/ in windows 7

Hi,

Under Windows 7 the function shinyDirChoose() coupled with getVolumes() is unable to select other volume but C:/

image

The problem comes from getVolumes().

A simple solution is to change the code in windows case by the following code:

else if (osSystem == "Windows") {
        volumes <- system("wmic logicaldisk get name", intern = T)
        volumes <- sub(" *\\r$", "", volumes)
        keep <- !tolower(volumes) %in% c("name", "")
        volumes <- volumes[keep]
        names(volumes) <- volumes
      }

The problem came from the parenthesis (, ) on the volumes' names.

By the way there is no need to launch the system command twice !

Here is the result after correction:

image

Shiny reset everything to default when click on shinyFile's shinyDirButton button.

While building a shiny app, there is a button to choose directory of files this button made by shinyFiles package. There are also some radio buttons on page or a button to show/hide Hide data chunk a div. Problem is after first time select the folder, then select any other radio button which was not default or click on show/hide button it becomes Show data chunk, then as soon as second time click on choose directory button it reset radio button to default selected and change the value of show/hide button to default which was at first time load page.

Why it reset these elements by click on second time to folder select?

Here is the code.

ui.R

library(shiny)
library(shinyFiles)
library(shinyjs)

shinyUI(fluidPage(
  titlePanel("Data Insights"),

  sidebarPanel(
    useShinyjs(),
    shinyDirButton('directory', 'Folder select', 'Please select a folder'),

   tags$div(id = "DrawChartFiltersWraper",
      uiOutput("chartsTypeControls")

    ),
  ),
  mainPanel(
      uiOutput('allStats'),
      tags$br(),
      uiOutput('dataChunkHeading')
  ),
))

server.R

shinyServer(function(input, output, session) {

# make data frame from CSV files.
dataFrame <- reactive({

  volumes <- getVolumes()
  shinyDirChoose(input,
               'directory',
               roots=volumes,
               session=session,
               restrictions=system.file(package='base'))

  validate (
    need(input$directory != "", "<< Please select a CSV folder"),
    errorClass = "missing-folder"
  )


  getDataFrame(parseDirPath(volumes, input$directory))

})


output$chartsTypeControls <- renderUI({

  chartTypes <- c("Bar Chart", "Pie Chart", "Scatterplot")
  radioButtons("chartTypes", "Choose Chart Type", chartTypes)
})


# data Chunk
output$dataChunkHeading <- renderUI({
  toggleDataChunk <- actionButton("toggleDataChunk", "Hide data chunk", class = "btn-primary")
  HTML(paste("<h3>Data chunk of provided data.</h3>", toggleDataChunk))
})

output$allStats <- renderUI({

    total_rows = nrow(dataFrame)
    total_columns = ncol(dataFrame)
    overAllTxt <- paste('<h3>Overall Insights</h3><br /><p>', "Total Rows:", total_rows, "Total Columns:", total_columns, "</p>")
    HTML(overAllTxt)
  })
})

Weird issue with updating other inputs

First of all, thanks for this very useful package!

I ran into a very weird issue, and I created a minimal example below to demonstrate one aspect of the issue (I'm still trying to find a small example that replicates the bigger issue I'm having in my shiny application, but I was hoping fixing this issue may at least shed light on the bigger issue).

Here's what's going on: if you click on the "file select" and selects a new file, it's supposed to update the textbox below with the file's name, but nothing happens. The button "Update File Name" works as expected. Any ideas or suggestions?

Thanks,
Yindeng

ui.r

library(shiny)
library(shinyFiles)

shinyUI(
  fluidPage(
    actionButton('update', 'Update File Name'),
    shinyFilesButton('file', 'File select', 'Please select a file', FALSE),
    textInput('fileName', 'File Name')
  )
)

server.r

library(shiny)
library(shinyFiles)

shinyServer(function(input, output, session) {
  dirRoots <- c('R Installation'=R.home())

  shinyFileChoose(input, 'file', roots=dirRoots, session=session, restrictions=system.file(package='base'))

  updateFileName <- function(){
    file <- (parseFilePaths(dirRoots, input$file))
    updateTextInput(session, 'fileName', value=file$name)
  }
  observeEvent(
    input$file, updateFileName()
  )
  observeEvent(
    input$update, updateFileName()
  )

}
)

Ehancement: Ability to type the file path

Hello,

First thank you for this great package. It was really useful to me in building a graphical user interface inside my own package. On user asked me if it was possible to add ability to type the file path in the shinyFiles file access to gain time ? It might be on good improvement of the existing file access engine.

Have a nice day,

Sylvain

Can't run simple example in README

I just tried running the very simple example in the README and I get an error. Here's the complete app:

library(shiny)
library(shinyFiles)

ui <- fluidPage(
  shinyFilesButton('files', label='File select', title='Please select a file', multiple=FALSE)
)

server <- function(input, output, session) {
  shinyFileChoose(input, 'files', root=c(root='.'), filetypes=c('', '.txt'))
}

shinyApp(ui = ui, server = server)

The error:

Warning: Error in observerFunc: argument "session" is missing, with no default
Stack trace (innermost first):
    57: observerFunc
     4: <Anonymous>
     3: do.call
     2: print.shiny.appobj
     1: <Promise>

sessionInfo:

R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252   
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shinyFiles_0.6.0  shiny_0.13.1.9000

loaded via a namespace (and not attached):
 [1] R6_2.1.2          rsconnect_0.4.1.9 htmltools_0.3.5   tools_3.2.2      
 [5] Rcpp_0.12.3       RJSONIO_1.3-0     jsonlite_0.9.19   digest_0.6.9     
 [9] xtable_1.8-2      httpuv_1.3.3      mime_0.4 

I tried with and without declaring a session parameter in the server function

Side effects between shinyFiles dialogs and shiny::renderUI elements

There seems to be an unwanted side effect between shinyFiles dialogs and the shiny functions renderUI and uiOutput. When opening a shinyFiles dialog, UI elements generated by uiOutput are reset to their initial value. UI elements generated directly in the shiny UI part are not affected. Tested with sliderInput and textInput, see

library(shiny)
library(shinyFiles)

runApp(list(
    ui = bootstrapPage(
      uiOutput("testSlider1"), br(),
      sliderInput("testSliderInput2", "testSliderInput2", 0, 100, 1, step = 1), br(),

      uiOutput("testText1"), br(),
      textInput("testTextInput2", "testTextInput2", value = ""), br(), 

      shinyFilesButton("testFilesButton", label="testFilesButton", title="testFilesButton", multiple=FALSE)
    ),
    server = function(input, output, session) {
      output$testSlider1 <- renderUI({
        sliderInput("testSliderInput1", "testSliderInput1", 0, 100, 1, step = 1)
      })

      output$testText1 <- renderUI({
        textInput("testTextInput1", "testTextInput1", value = "")
      })

      shinyFileChoose(input, "testFilesButton", session=session, roots=c(wd='.'))
    }
))

Thanks

Opening folders on touch devices

My shiny app is used mainly on touch devices and I found that I can't get into folders using them. It seems that a "double click" is necessary for opening a folders. Any idea how I can open a folder using touch?

Allow multiple virtual volumes as root

Default the constructor to all volumes/disks. Nee to create a function that get system dependant list of volumes/drives. Use wmic logicaldisk get caption in windows to get all drives. Use mount point on unix systems...

Select by pattern

Hi,

Please, It is possible to filter by file extension, but would it also be able to filter by pattern in the file name?

Example: if my folder had: "file_input.rda","file_output.rda", "file.pdf". And we want only files with input pattern in the name.

Thanks!

Can't use shinyFiles without explicitly loading it via library()

Here's a simple use of shinyFiles with namespacing instead of using library():

library(shiny)

ui <- fluidPage(
  shinyFiles::shinySaveButton("backup", "Save file", "Save file as...", filetype = list(RData = "RData"))
)

server <- function(input, output, session) {
  shinyFiles::shinyFileSave(input, "backup", roots = shinyFiles::getVolumes(),
                session = session, restrictions = system.file(package = "base"))
}

shinyApp(ui = ui, server = server)

This does not work. When I look in the JS console, I see that there are errors trying to fetch JS and CSS files. This pointed me to believe that the resources are not found because a resource path is not being declared. It looks like the resource path gets added when the package is attached, which would explain why this happens.

It'd be nice to be able to use the package without having to call library(), because calling library() inside package code is bad and some people want to use your functions in other packages

parseSavePath crashes if shinySaveButton does not have filetype

Hi,

Thanks for your work on this package and congratulations on your PhD (I assume you have finished it since there is a new version of shinyFiles around).

Going to the issue...:

If shinySaveButton does not have filetype specified, it is set to null by formatFiletype. Then parseSavePath will crash at the data.frame(name = selection$name, type = selection$type, datapath = savefile) because the type column will be NULL..

I am not familiar enough with shiny to provide a solution (maybe replacing the type if it is NULL by something else?). I hope the issue is clear enough and hopefully you will be able to fix this.

Thanks again!

Multiple directories selection

Hi Thomas,

I'm using this package and like it very much. But did you support to select multiple directories ? If yes, please tell me how to do it.

Thanks.

Crosstalk with rpivotTable

Hi nice package, just Started using this package, so I really hope this isn't a stupid issue.

I am trying to load multiple files, and then render some output in a pivottable (using rpivotTable).

When I try with both packages in the same app there appears to be a bug that seems to be caused by js crosstalk between the two (I am not an expert so can't tell you where, but the js traceback seems to imply shinyFiles calling an htmlWidgets function at some point).

Example code

library(shiny)
library(rpivotTable)
library(shinyFiles)

# Define server logic required to draw a histogram
server <- function(input, output, session){
  #volumes <- getVolumes()
  volumes <- c(`Local (C)`="C:", 
               `Data (M)`="M:")
  shinyFileChoose(input = input, 
                  id = 'file', 
                  roots = volumes, 
                  session = session)
  output$filepaths <- renderPrint({parseFilePaths(volumes, input$file)})
  output$bPivotTable <- renderRpivotTable({
    rpivotTable(data = iris)
  })
}

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
        fluidRow(strong("Choose files to upload:")),
        fluidRow(
          shinyFilesButton(id = "file", 
                           label = "Files", 
                           title = "Upload Files",
                           multiple = TRUE)
        )
    ),
    mainPanel(
      verbatimTextOutput('filepaths'), 
      rpivotTableOutput("bPivotTable")  
    )
  )
)

print(shinyApp(ui = ui, server = server))

just comment out the rpivotTableOutput("bPivotTable") line and rerun to see the difference when clicking on the button. (The directories are missing).

The number of dependents on htmlWidgets means that a shinyFiles fix might be a more logical solution?

shinythemes not supported

I had an issue trying to have both a theme and i/o with shinyFiles. MWE is the shinyFilesExample() with a theme added

library(shinythemes)
https://rstudio.github.io/shinythemes/

When I go to browse a file with any of the buttons, the screen gets grey-ed out and I can't navigate/select.

Thanks!

Error with R 3.4

Hi Thomas,

When loading a Shiny app with 3.4, I get this message:

Warning in body(fun) : argument is not a function
Warning in structure(x, class = unique(c("AsIs", oldClass(x)))) :
Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
Consider 'structure(list(), *)' instead.

When I click on the ShinyFiles button to save a variable, no folder appears on the menu, and when I close the window the app crashes with this message:

Warning: Error in [[: subscript out of bounds
Stack trace (innermost first):
58: fileGet
57: do.call
56: observerFunc
1: runApp

ATB

Daniel

ShinyFiles and shared drive

I use drive letters on Windows to refer to shared drives. ShinyFiles works great for directories on my C drive, but it doesn't work for shared drives. I can actually refer to the initial location (e.g. 'F:/'), I see all the subfolders but I can't click on them. If I refer directly to a subfolder on the shared drive, the filepicker doesn't work at all. I tried via a shortcut on the desktop, but he ignores shortcuts (for good reasons as they can lead you somewhere else).

shinyFiles and shiny js bad interaction

There is bug if there are at least two shinyFile objects and at least one is created disabled with shinyjs, then the remaining enabled shinyFile object will show the file dialog TWICE. (or it could be that it opens the window twice and that I only see the underlying one when I close the top one).

Creating the item normally and later disabling it does not cause the bug -- it must be created disabled. They do not need to be the same kind of shinyFiles object.

I do not know if the bug is in shinyjs, shinyFiles or the interaction so I cross-listing it in both projects. Here is the link to the issue at shinyjs: daattali/shinyjs#120

shinyFiles_shinyjs_bad_interaction.zip

parseSavePath gets an error when no file extensions specified in save dialog

PeterVermont_modified_example.zip

Using version 0.6.2

There are two errors, both viewable in the attached minor modification of your example

  1. you must hit the "Save' button twice. This was true in the packaged released version with no modifications.
    2 If no file extensions are passed to the save then calling parseSavePath gets this error:

Warning: Error in data.frame: arguments imply differing number of rows: 1, 0
Stack trace (innermost first):
67: data.frame
66: parseSavePath
65: observeEventHandler [C:\Users\peter.andrews\Documents\R\win-library\3.3\shinyFiles\example/server.R#16]
1: runApp
Warning: Error in data.frame: arguments imply differing number of rows: 1, 0
Stack trace (innermost first):
87: data.frame
86: parseSavePath
85: renderPrint [C:\Users\peter.andrews\Documents\R\win-library\3.3\shinyFiles\example/server.R#11]
84: func
83: eval
82: eval
81: withVisible
80: evalVis
79: utils::capture.output
78: paste
77: origRenderFunc
76: output$savefile
1: runApp
ERROR: [on_request_read] connection reset by peer

Download from navbar?

shinyFiles looks really interesting! Just wondering if what I asked in the post linked below might be possible with shinyFiles

https://groups.google.com/forum/?fromgroups=#!topic/shiny-discuss/x-OJgz5PSH8

I would point you to the shiny-server version of the app I am using but it is misbehaving. The full app is on github at:

https://github.com/mostly-harmless/radiant

Basically, what I want to do is offer users the option to Quit the app from the navbar but give them an extra reminder to Save the full state of the app for later reference. So Save is part of the Quit dropdown. What I do now is redirect a user that clicked on Save to the State page. This is ok but I would rather just start the app-state-download dialog directly. Students will predominantly be using the app locally on their computers.

Name check in 'Create folder'

Currently name is not checked before allowing a create folder request. On name clashes with other files and folders it silently fails

display two directories

Hi, I see this issue was posted a while back (#20). But i'm wondering if there is support to select one directory, display that tree, then go back and select a second directory and display them both. Do you have any advice for that?
Thank you!

Companion tools: file explorer/manager, batch/queue

Hi,

It's a pleasure to use shinyFiles.

In order, to integrate a set of tools via the shiny interface, did you plan to develop a file explorer or manager in order to:

  • upload files asynchronously before processing them,
  • review/browse HTML/markdown results if any.

In addition, a batch or a queue manager would be useful.

Best.

shinyFilesExample File select doesn't work

On this system:

R version 3.2.1 (2015-06-18)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.9.5 (Mavericks)

with shinyFiles_0.6.0 and shiny_0.12.2,

when I run shinyFilesExample(), the Folder Select button works fine, but the File Select button doesn't work at all. I get the attached mostly-blank window. None of the buttons do anything. There's no error in the console.

Any ideas?

shinyfiles-issue

Including shinyFiles in shiny module

When including shinyFiles into a shiny module, when clicking the shinyFilesButton() the navigation window shows no files. If the same code is run not in a module it works as expected. I am wondering if something in the design of shinyFiles prevents it from working nicely with the new shiny modules. This happens with shinyFiles_0.6.0 and shiny_0.13.1. Here is a minimal reproducible example:

require(shiny)
require(shinyFiles)

# this works.
ui <-
  fluidPage(shinyFilesButton("add", "Add", "Please select a file", FALSE))

server <- function(input, output, session) {
  shinyFileChoose(input,
                  "add",
                  session = session,
                  roots = c(wd = '.'))
}

shinyApp(ui, server)

## module set up.
selectFilesInput <- function(id, label = "Select files") {
  ns <- NS(id)
  tagList(shinyFilesButton(ns("add"), "Add", "Please select a file", FALSE))
}

selectFiles <- function(input, output, session) {
  shinyFileChoose(input,
                  "add",
                  session = session,
                  roots = c(wd = '.'))
}

# this does not work (shows button but not files when clicked).
ui <- fluidPage(selectFilesInput("foo"))

server <- function(input, output, session) {
  datafile <- callModule(selectFiles, "foo")
}

shinyApp(ui, server)

Directory contains files but content shows "Empty folder"

Hi Thomas,

It seems when using shinyDirButton to choose directory, in the modal interface, content part, only directories can be shown, and it shows "Empty folder" even if the folder contains files. I guess this is a bug?

Btw, your package is awesome.

Thanks,
Qin

screen shot 2015-11-06 at 5 27 31 pm

output update in shinyFileChoose

Hi Thomas,

I'm playing around with your package, nice stuff!

I have a small issue: When I run shinyFileExample(), the fields 'verbatimTextOutput' containing the chosen files/dir never update. Same problem when I write a function by myself. Although, funny enough, on exiting with stopApp(), I get the chosen file/dir out.

Cheers
Lorenz

class "connection" warning

Hi,

I am using Bioconductor pacakges in an Shiny app, and I keep getting this message

Found more than one class "connection" in cache; using the first, from namespace 'BiocGenerics'

If I am not mistaken, it seems to me that problem is caused by the RJSONIO package that ShinyFiles depends on. The class "connection" in RJSONIO is probably also the name of another class in BiocGenerics.

Is there a quick fix to this?

shinyFiles not binding with renderUI output

Hi Thomas,

I tried to use your package in a dynamic shiny page rendering the output with renderUI, but the observer does not seem to trigger when clicking the button. The same code works if the shinyFilesButton() function is called in the ui somewhere.

shinyApp(
  ui = fluidPage(
    sidebarLayout(
      sidebarPanel(uiOutput("loadFileOutPut")),
      mainPanel()
    )
  ), 
  server = function(input, output, session) {
    shinyFileChoose( input = input, id = "loadFile", session = session, roots = c( "project" = getwd()))

    output$loadFileOutPut <- renderUI({
      shinyFilesButton( "loadFile", "Load a file", "Load a file", multiple = FALSE ) 
    })
  }
)

import functions from htmltools (solves the addResourcePath() problem)

The objects tagList, tags, and singleton have been moved to htmltools, so here is what you probably need to do accordingly:

diff --git a/NAMESPACE b/NAMESPACE
index 75a0be8..5d1d142 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -5,11 +5,11 @@ export(parseFilePaths)
 export(shinyFileChoose)
 export(shinyFilesButton)
 export(shinyFilesExample)
+importFrom(htmltools,singleton)
+importFrom(htmltools,tagList)
+importFrom(htmltools,tags)
 importFrom(shiny,addResourcePath)
 importFrom(shiny,invalidateLater)
 importFrom(shiny,reactive)
 importFrom(shiny,runApp)
-importFrom(shiny,singleton)
-importFrom(shiny,tagList)
-importFrom(shiny,tags)
 importFrom(tools,file_ext)
diff --git a/R/aaa.R b/R/aaa.R
index 3aa9322..9bf46af 100644
--- a/R/aaa.R
+++ b/R/aaa.R
@@ -1,6 +1,7 @@
 #' Adds the content of www to sF/
 #' 
 #' @importFrom shiny addResourcePath
+#' @importFrom htmltools singleton
 #' 
 #' @noRd
 #' 
diff --git a/R/filechoose.R b/R/filechoose.R
index 762ccfa..0740a09 100644
--- a/R/filechoose.R
+++ b/R/filechoose.R
@@ -213,7 +213,7 @@ shinyFileChoose <- function(input, inputId, updateFreq=2000, session=NULL, ...)
 #' @references The file icons used in the file system navigator is taken from
 #' FatCows Farm-Fresh Web Icons (\url{http://www.fatcow.com/free-icons})
 #' 
-#' @importFrom shiny tagList singleton tags
+#' @importFrom htmltools tagList tags
 #' 
 #' @export
 #' 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.