I am getting started on using Rhino framework for ShinyApps in R.
I am writing my code in VSCode, when I run the below, the app works fine in my browser. However, whenever a file is above 5MB it flags max file size exceeded.
All fine, as I've seen that using options(shiny.maxRequestSize=30*1240^2) that reset the default to 30MB. However, when I'm writing the following code, my app is still not accepting heavier files.
Example:
the logic just reads in some data, and provides a plotting function to sense check the file has been ingested correctly.
# app/logic/read_function
box::use(readr[read_csv],janitor[clean_names])
#' @export
create_file_to_read <- function(file_to_read){
if (is.null(file_to_read)){
return("Please enter a file!")
} else {
df <- read_csv(file_to_read$datapath) |>
clean_names()
return(df)
}
#' @export
check_plot <- function(df){
check_plot <- plot(df)
return(check_plot)
}
the view makes the reactive connection between the file input and the df I need.
# app/view/check_view
box::use(shiny[...])
box::use(app/logic/read_function)
shinyOptions(shiny.maxRequestSize=30*1240^2)
#' @export
ui <- function(id){
ns <- NS(id)
fileInput(inputId=ns("InputFile"),
label="Please enter a csv file:",
accept=c(".csv")),
tableOutput(ns("files")),
plotOutput(ns("check_plot"))
}
#' @export
server <- function(id){
shinyOptions(shiny.maxRequestSize=30*1024^2)
moduleServer(id, function(input, output, session){
# read in the data and render a table in the ui for files input
data_df <- reactive({ read_function$create_file_to_read(file_to_read=input$InputFile)})
output$files <- renderTable({ input$InputFile })
# plot
output$check_plot <- renderPlot({ check_plot(df=data_df()) })
})
}
And the final file:
# app/main.R
box::use(app/logic/read_function,
app/view/check_view)
box::use(shiny[...])
shinyOptions(shiny.maxRequestSize=30*1240^2)
ui <- function(id){
ns <- NS(id)
check_view$ui("checks")
}
server <- function(id){
moduleServer(id, function(input, output, session){
check_view$server("checks")
})
}
What am I missing, is there a particular line or location where this line is supposed to go to take effect? Does it go in the individual module or in the main app.R file?
In my original, I did not use any shinyOptions expressions, but since reading that it affected the permissable file input size, and also not knowing where to place it, I have reproduced the expression twice in both the view and main files. The app works and launches in my browser fine, but it is still not accepting files larger than 5MB.
Also, how should I go about this were I to look at deploying on shinyapps.io?