| Title: | File Sharing Shiny Module |
|---|---|
| Description: | Shiny module for easily sharing files between users. Admin can add, remove, edit and download file. User can only download file. It's also possible to manage files using R functions directly. |
| Authors: | Benoit Thieurmel [aut, cre], Thibaut Dubois [aut], Jérémy Boussaguet [ctb] |
| Maintainer: | Benoit Thieurmel <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.5 |
| Built: | 2026-06-04 08:25:50 UTC |
| Source: | https://github.com/cran/shinydrive |
Add / suppress / edit a file
add_file_in_dir( file, dir, yml, name = tools::file_path_sans_ext(basename(file)), description = "", date_time_format = "%Y%m%d_%H%M%S" ) edit_file_in_dir( id, dir, yml, name = NULL, description = NULL, file = NULL, date_time_format = "%Y%m%d_%H%M%S" ) suppress_file_in_dir(id, dir, yml) get_yaml_info( yml, recorded_name = TRUE, date_time_format = "%Y%m%d_%H%M%S", add_img = FALSE, img_size = 30, format_size = TRUE )add_file_in_dir( file, dir, yml, name = tools::file_path_sans_ext(basename(file)), description = "", date_time_format = "%Y%m%d_%H%M%S" ) edit_file_in_dir( id, dir, yml, name = NULL, description = NULL, file = NULL, date_time_format = "%Y%m%d_%H%M%S" ) suppress_file_in_dir(id, dir, yml) get_yaml_info( yml, recorded_name = TRUE, date_time_format = "%Y%m%d_%H%M%S", add_img = FALSE, img_size = 30, format_size = TRUE )
file |
|
dir |
|
yml |
|
name |
|
description |
|
date_time_format |
|
id |
|
recorded_name |
|
add_img |
|
img_size |
|
format_size |
|
These functions return a logical indicating if operation succeeded or not
## Not run: yml <- file.path(getwd(), "test_sfm/config.yml") # will be created dir <- file.path(getwd(), "test_sfm") dir.create(dir) file <- system.file("translate/translate.csv", package = "shinydrive") # add one first file with current name add_file_in_dir( file = file, dir = dir, yml = yml, description = "" ) yaml::yaml.load_file(yml) list.files(dir) get_yaml_info(yml) # add same file twice, changing name add_file_in_dir( file = file, dir = dir, yml = yml, name = "translate_2", description = "This is cool" ) yaml::yaml.load_file(yml) list.files(dir) get_yaml_info(yml, recorded_name = F) # modify first file edit_file_in_dir( id = "2", dir = dir, yml = yml, name = "translate_2_mod", description = "So cool" ) yaml::yaml.load_file(yml) list.files(dir) # suppress first file suppress_file_in_dir(id = "1", dir = dir, yml = yml) yaml::yaml.load_file(yml) list.files(dir) ## End(Not run)## Not run: yml <- file.path(getwd(), "test_sfm/config.yml") # will be created dir <- file.path(getwd(), "test_sfm") dir.create(dir) file <- system.file("translate/translate.csv", package = "shinydrive") # add one first file with current name add_file_in_dir( file = file, dir = dir, yml = yml, description = "" ) yaml::yaml.load_file(yml) list.files(dir) get_yaml_info(yml) # add same file twice, changing name add_file_in_dir( file = file, dir = dir, yml = yml, name = "translate_2", description = "This is cool" ) yaml::yaml.load_file(yml) list.files(dir) get_yaml_info(yml, recorded_name = F) # modify first file edit_file_in_dir( id = "2", dir = dir, yml = yml, name = "translate_2_mod", description = "So cool" ) yaml::yaml.load_file(yml) list.files(dir) # suppress first file suppress_file_in_dir(id = "1", dir = dir, yml = yml) yaml::yaml.load_file(yml) list.files(dir) ## End(Not run)
Combine YAML files recursively from subdirectories
combine_yaml_recursive( base_dir, current_dir = "", config_file = "files_desc.yaml", recorded_name = TRUE, date_time_format = "%Y%m%d_%H%M%S", add_img = FALSE, img_size = 30, format_size = TRUE )combine_yaml_recursive( base_dir, current_dir = "", config_file = "files_desc.yaml", recorded_name = TRUE, date_time_format = "%Y%m%d_%H%M%S", add_img = FALSE, img_size = 30, format_size = TRUE )
base_dir |
Base directory path |
current_dir |
Current directory relative to base_dir (use "" for base_dir itself) |
config_file |
YAML configuration file name |
recorded_name |
Add recorded name (with date_time extension) in output? |
date_time_format |
DateTime format |
add_img |
Use in shiny module for adding file extension img |
img_size |
Use in shiny module for adding file extension img |
format_size |
User-friendly size format? |
A data frame combining all YAML files with a 'subdir' column indicating relative path
## Not run: # Get all files from base_dir and subdirectories all_files <- combine_yaml_recursive( base_dir = "~/my_files", current_dir = "", config_file = "files_desc.yaml" ) # Get files from a specific subdirectory and its children subdir_files <- combine_yaml_recursive( base_dir = "~/my_files", current_dir = "projects/2024", config_file = "files_desc.yaml" ) ## End(Not run)## Not run: # Get all files from base_dir and subdirectories all_files <- combine_yaml_recursive( base_dir = "~/my_files", current_dir = "", config_file = "files_desc.yaml" ) # Get files from a specific subdirectory and its children subdir_files <- combine_yaml_recursive( base_dir = "~/my_files", current_dir = "projects/2024", config_file = "files_desc.yaml" ) ## End(Not run)
Delete all YAML files
delete_config( base_dir, config_file = "files_desc.yaml", confirm = TRUE, dry_run = FALSE, verbose = TRUE )delete_config( base_dir, config_file = "files_desc.yaml", confirm = TRUE, dry_run = FALSE, verbose = TRUE )
base_dir |
Folder to check for YAML files |
config_file |
YAML files names |
confirm |
With or without confirmation before deleting |
dry_run |
simulation (no deletion) |
verbose |
Display messages |
delete all yaml files
## Not run: \donttest{ delete_config("~/shinydrive/tests", config_file = "files_desc.yaml") } ## End(Not run)## Not run: \donttest{ delete_config("~/shinydrive/tests", config_file = "files_desc.yaml") } ## End(Not run)
Delete config files older than a specific number of days
delete_old_config( base_dir, days = 30, config_file = "files_desc.yaml", confirm = TRUE, dry_run = FALSE, verbose = TRUE )delete_old_config( base_dir, days = 30, config_file = "files_desc.yaml", confirm = TRUE, dry_run = FALSE, verbose = TRUE )
base_dir |
base folder |
days |
number of days to check the age of files we want to delete |
config_file |
name of YAML files |
confirm |
With or without confirmation before deleting |
dry_run |
Simulation |
verbose |
Display messages |
delete old config files from folder
delete_old_config("~/shinydrive/tests", days = 60, config_file = "files_desc.yaml")delete_old_config("~/shinydrive/tests", days = 60, config_file = "files_desc.yaml")
Create YAML configuration files recursively
init_config( base_dir, config_file = "files_desc.yaml", file_patterns = NULL, verbose = TRUE )init_config( base_dir, config_file = "files_desc.yaml", file_patterns = NULL, verbose = TRUE )
base_dir |
Base directory path |
config_file |
YAML configuration file name |
file_patterns |
File patterns to match |
verbose |
Display messages |
Invisible count of processed directories
File management shiny module.
shiny_drive_ui(id) shiny_drive_server( input, output, session, id, save_dir, dir_access = NULL, admin_user = TRUE, force_desc = FALSE, lan = "EN", file_translate = read.csv(system.file("translate/translate.csv", package = "shinydrive"), sep = ";", encoding = "UTF-8", check.names = FALSE), datatable_options = list(), yml = "files_desc.yaml", date_time_format = "%Y%m%d_%H%M%S", decreasing = TRUE, intervalMillis = 5000 )shiny_drive_ui(id) shiny_drive_server( input, output, session, id, save_dir, dir_access = NULL, admin_user = TRUE, force_desc = FALSE, lan = "EN", file_translate = read.csv(system.file("translate/translate.csv", package = "shinydrive"), sep = ";", encoding = "UTF-8", check.names = FALSE), datatable_options = list(), yml = "files_desc.yaml", date_time_format = "%Y%m%d_%H%M%S", decreasing = TRUE, intervalMillis = 5000 )
id |
|
input |
shiny input |
output |
shiny input |
session |
shiny input |
save_dir |
|
dir_access |
|
admin_user |
|
force_desc |
|
lan |
|
file_translate |
|
datatable_options |
|
yml |
|
date_time_format |
|
decreasing |
|
intervalMillis |
|
Shiny module without return value.
## Not run: if(require(shiny)){ ui <- fluidPage( shiny_drive_ui(id = "idm") ) server <- function(input, output, session) { callModule(module = shiny_drive_server, id = "idm", session = session, admin_user = TRUE, save_dir = getwd(), lan = "FR") } shinyApp(ui, server) } ## End(Not run)## Not run: if(require(shiny)){ ui <- fluidPage( shiny_drive_ui(id = "idm") ) server <- function(input, output, session) { callModule(module = shiny_drive_server, id = "idm", session = session, admin_user = TRUE, save_dir = getwd(), lan = "FR") } shinyApp(ui, server) } ## End(Not run)