Is there a way to rename a file before uploading it to dropbox with drop_upload in shiny?

208 views Asked by At

I'm using drop_upload upload a file shiny. The problem is that my file that gets uploaded is named "0". I would like to change the name of the file based on the file that I implemented with the function fileInput. For example, if I implement a file "yo.csv", I want to separate "yo" and ".csv" and rename the file "something_yo_this_is_aCSV.csv". On the contrary, if I input "yo.xlsx", I want to rename the file "something_yo_this_is_aEXCEL.xlsx" before uploading it to dropbox. Is there a way to do this?

UI (among other stuff):

  ## Upload data!
  fileInput(inputId = 'upload', 
            label = 'Choose CSV File',
            accept=c('text/csv', 
                     'text/comma-separated-values,text/plain', 
                     '.csv'),
            multiple = FALSE),

Server (among other stuff):

    drop_upload(input$upload$datapath, 
                dest = "responses/dataframes")

This is the option I found so far, but it can only save the file locally (Desktop for example...). In this case the file would be saved as foo.csv.

  if (is.null(input$upload)) return()
  file.copy(from = input$upload$datapath, 
            to = paste("~/Desktop/",
                       outputDir,
                       "/foo.csv", sep = "")) # Where to save the file 
0

There are 0 answers