Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control file name in drop_upload() #180

Open
JonasGeschke opened this issue Mar 11, 2020 · 2 comments
Open

Control file name in drop_upload() #180

JonasGeschke opened this issue Mar 11, 2020 · 2 comments

Comments

@JonasGeschke
Copy link

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().

@JonasGeschke
Copy link
Author

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")

@jamessmythe
Copy link

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))
                 
  })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants