How to update the .RDS file with the files user uploads and store it for next time in Shiny (server)?

Basically, there are 50 files which are about 50 MB each and therefore, processed them and made 30k rows processed data as .RDS file to render some visualization.
However, User needs the app to upload recent files and keep updating the visualization.

Is it possible to update the .RDS file with the files user uploads ?
Can the user access this updated .RDS file even next time (session) ?

In the following example,
there is an upload button and render just a file.
Can we store the uploaded files somehow ?
So, that, we can use these uploaded files to update the .RDS file

relevant links:


# Define UI for data upload app ----
ui <- fluidPage(

  # App title ----
  titlePanel("Uploading Files"),

  # Sidebar layout with input and output definitions ----

    # Sidebar panel for inputs ----

      # Input: Select a file ----
      fileInput("files", "Upload", multiple = TRUE, accept = c(".csv"))
# In order to update the database if the user clicks on the action button
 actionButton("update_database","update Database")

    # Main panel for displaying outputs ----
      # Output: Data file ----



# Define server logic to read selected file ----
server <- function(input, output) {
  lst1 <- reactive({
    validate(need(input$files != "", "select files..."))

##### Here, .RDS file can be accessed and updated for visualiztaion

    if (is.null(input$files)) {
    } else {

      path_list <- as.list(input$files$datapath)
      tbl_list <- lapply(input$files$datapath, read.table, header=TRUE, sep=";")

      df <-, tbl_list)

  output$tbl_out <- renderDataTable({
##### Can also access this data for visualizations

    s3save(appended_data, object = "object_path_of_currentRDS_file",bucket = "s3_bucket")


# Create Shiny app ----
shinyApp(ui, server)

But there was an error:
Warning: Error in private$closedCallbacks$register: callback must be a function
  50: stop
  49: private$closedCallbacks$register
  48: session$onSessionEnded
  47: server [/my_folder_file_path.R#157]
Error in private$closedCallbacks$register(sessionEndedCallback) : 
  callback must be a function


replace this code

    s3save(appended_data, object = "object_path_of_currentRDS_file",bucket = "s3_bucket")

######## with this #####

    s3saveRDS(appended_data, object = "object_path_of_currentRDS_file",bucket = "s3_bucket")
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.