shinyFiles-observers | R Documentation |
These function sets up the required connection to the client in order for the
user to navigate the filesystem. For this to work a matching button should be
present in the html, either by using one of the button generating functions
or adding it manually. See shinyFiles-buttons()
for more details.
shinyFileChoose( input, id, updateFreq = 0, session = getSession(), defaultRoot = NULL, defaultPath = "", ... ) shinyDirChoose( input, id, updateFreq = 0, session = getSession(), defaultPath = "", defaultRoot = NULL, allowDirCreate = TRUE, ... ) shinyFileSave( input, id, updateFreq = 0, session = getSession(), defaultPath = "", defaultRoot = NULL, allowDirCreate = TRUE, ... )
input |
The input object of the |
id |
The same ID as used in the matching call to
|
updateFreq |
The time in milliseconds between file system lookups. This determines the responsiveness to changes in the filesystem (e.g. addition of files or drives). For the default value (0) changes in the filesystem are shown only when a shinyFiles button is clicked again |
session |
The session object of the shinyServer call (usually
|
defaultRoot |
The default root to use. For instance if
|
defaultPath |
The default relative path specified given the |
... |
Arguments to be passed on to |
allowDirCreate |
Logical that indicates if creating new directories by the user is allowed. |
Restrictions on the access rights of the client can be given in several ways.
The root parameter specifies the starting position for the filesystem as
presented to the client. This means that the client can only navigate in
subdirectories of the root. Paths passed of to the restrictions
parameter will not show up in the client view, and it is impossible to
navigate into these subdirectories. The filetypes
parameter takes a
vector of file extensions to filter the output on, so that the client is
only presented with these filetypes. The hidden
parameter toggles
whether hidden files should be visible or not. Whenever a file or folder
choice is made the resulting files/folder will be accessible in the input
variable with the id given in the parameters. This value should probable be
run through a call to one of the parser (shinyFiles-parsers()
) in
order to get well formatted paths to work with.
A reactive observer that takes care of the server side logic of the filesystem connection.
The syntax for this version has changed with version 0.4.0. Prior to
that version the output of shinyFileChoose()
should be assigned to the
output object. This is no longer the case and doing so will result in an
error. In newer versions the function returns an observer which can be
ignored for the most part, or assigned to a variable if there needs to be
interactions with it later on.
Other shinyFiles:
shinyFiles-buttons
,
shinyFiles-parsers
,
shinyFilesExample()
## Not run: # File selections ui <- shinyUI(bootstrapPage( shinyFilesButton('files', 'File select', 'Please select a file', FALSE) )) server <- shinyServer(function(input, output) { shinyFileChoose(input, 'files', roots=c(wd='.'), filetypes=c('', 'txt'), defaultPath='', defaultRoot='wd') }) runApp(list( ui=ui, server=server )) ## End(Not run) ## Not run: # Folder selections ui <- shinyUI(bootstrapPage( shinyDirButton('folder', 'Folder select', 'Please select a folder', FALSE) )) server <- shinyServer(function(input, output) { shinyDirChoose(input, 'folder', roots=c(wd='.'), filetypes=c('', 'txt')) }) runApp(list( ui=ui, server=server )) ## End(Not run) ## Not run: # File selections ui <- shinyUI(bootstrapPage( shinySaveButton("save", "Save", "Save as...") )) server <- shinyServer(function(input, output) { shinyFileSave(input, "save", roots = c(wd = ".")) }) runApp(list( ui = ui, server = server )) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.