rdrop2
rdrop2 copied to clipboard
Control file name in drop_upload()
I am building a shiny app where users can upload files that get stored in a dropbox. The files are just saved but not further used for analysis in the app.
In addition to #173, I would like to ask if it is possible to include an argument in drop_upload()
that sets the file name for the file that is being uploaded.
Right now I implemented a workaround to create a folder for each file, with the name file name as folder name. Each "0"-named file gets saved in this specific folder. However, a control argument for the file name to be saved as would be more efficient.
Would be great if you consider implementing and adding such an argument to drop_upload()
.
If people are interested, I provide my workaround code here:
file <- input$file if(TRUE %!in% grep(file$name, drop_dir(FILEoutput)$name)){ fileoutputfolder <- paste(FILEoutput,"/", file$name,"", formatC(1, width=3, flag="0"),sep="") } if(TRUE %in% grep(file$name, drop_dir(FILEoutput)$name)){ folderno <- length(grep(file$name, drop_dir(FILEoutput)$name)) fileoutputfolder <- paste(FILEoutput,"/", file$name,"", formatC(folderno+1, width=3, flag="0"),sep="") } drop_create(path = fileoutputfolder) drop_upload(file$datapath, path = fileoutputfolder, mode = "add")
an argument added in drop_upload()
setting the filename as character would allow keeping only the first and last row...
file <- input$file drop_upload(file$datapath, filename = paste("anycharacter"), path = fileoutputfolder, mode = "add")
Hi Jonas
I worked around by saving the incoming file to a temporary directory with its $name property, not $filepath, then writing this file out to dropbox...
observeEvent(input$myFile, {
inFile <- input$myFile
if (is.null(inFile))
return()
dir.create("tempdir")
file.copy(inFile$datapath, file.path("tempdir", inFile$name))
drop_upload(dtoken = token,
file = paste0("tempdir/",inFile$name))
})