This is my first answer but i worked a lot with Shiny.
Of course you can do what you ask for. You just need to merge the fileInput function and the downloadButton / downloadLink.
https://shiny.rstudio.com/reference/shiny/1.0.4/downloadButton.html
https://shiny.rstudio.com/gallery/file-upload.html
Here i wrote a quick example, you just need to copy and save with the name app.R :
library(shiny)
# Define UI for data upload app ----
ui <- fluidPage(
# App title ----
titlePanel("Welcome to Ethar data transformation app"),
# App subtitle
h4(HTML("Upload your file and click the Download button")),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel ----
sidebarPanel(
# Input: Select a file ----
fileInput("fileUploaded", "Choose CSV File",
multiple = FALSE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
# Output: Download a file ----
downloadButton('downloadFile', 'Process the file & Download', class= "action"),
# CSS style for the download button ----
tags$style(type='text/css', "#downloadFile { width:100%; margin-top: 35px;}")
),
# Main panel for displaying outputs ----
mainPanel(
# Output: Data file ----
textOutput("done")
)
)
)
# Define server logic to read selected file ----
server <- function(input, output) {
# Download handler in Server
output$downloadFile <- downloadHandler(
filename = function() {
paste('dataProcessed-', Sys.Date(), '.csv', sep='')
},
content = function(con) {
originalData <- input$fileUploaded
##############################
# Transformations in originalData object
##############################
dataProcesed <- originalData
write.csv(dataProcesed, con)
output$done <- renderText({
ifelse(!is.null(dataProcesed),"Transformation done! :D","Error during the process :(")
})
}
)
}
# Create Shiny app ----
shinyApp(ui, server)
Hope it helps! :)