I was wondering if there is a way to upload several files by one single file containing its names. E.g I have a .txt that has 3 rows with "File 1.txt" "File 2.txt" and "File 3.txt" and I want to upload those 3 files in that order (The file with the names is in the same folder that the to be uploaded files).
I don't want to use fileInput(..., multiple = TRUE)
because when you upload multiple files are ordered by default alphabetically. With a few files the user can change the names to be uploaded this way, but if you have a lot of files it became an annoying task.
I've thougth that I could paste the name to the last part of the datapath, but when the file is uploaded the datapath is in the local temp and not the actual location of the file, as shown in the figure below.
Thanks!
CodePudding user response:
When a file is uploaded by Shiny WEB application the file is assigned a new name and is stored in temp folder of server. All the reads are done with this server-side stored file. The server does not have priveleges to get access to client's file system and is not capable to read any files from client's PC. So there are no obvious ways to solve the stated task in the desired way and I guess it shouldn't be used even the way is found as it opens the gate for risks of unauthorized file system access.
I guess if the task cannot be solved in any altetnative way you have to consider a UI interface with an arranged list of files creation, client side packing and sending to server side.
CodePudding user response:
If there is any sort of pattern to the files you want to process, you might still be able to use multiple = T within fileinput for serverside processing.
My example below arranges on size of the uploaded files, but you could create a custom order on the name attribute as well (assuming you will be using this list as an index for your processing).
library(shiny)
library(magrittr)
ui <- fluidPage(
fileInput(inputId = "fileinput",
label = "select",
multiple = TRUE)
)
server <- function(input,output,session) {
observeEvent(input$fileinput, {
print(input$fileinput %>% dplyr::arrange(desc(size)))
})
}
shinyApp(ui,server)