There are three main parts of the server code:
-
The first sets up an observer which writes to a log file once every second. This is just to make the example work; typically some external process will be writing to a file.
-
The second part uses a
reactiveFileReader
to monitor the log file for changes every 0.5 seconds. -
The third part uses a
reactivePoll
to monitor the log file for changes every 4 seconds. ThereactivePoll
is general, and it watch for things other than file changes. It could, for example, query a database.
Hi, I'm trying to use reactiveFileReader to read from an s3 bucket that'll be updated periodically. Can't seem to get it to work. Any suggestions? Currently, my code looks like
`getFile<-function(){
my_bucket <- 'globalrss'
file <- paste0(as.character(getwd()),"/tmp")
r <- aws.s3::save_object("bodytype.csv", my_bucket, file=file)
}
shinyServer(function(input, output, session) {
fileReaderData <- reactiveFileReader(500, session,
getFile(), readLines)
output$fileReaderText <- renderText({
text <- fileReaderData()
length(text) <- 14
text[is.na(text)] <- ""
paste(text, collapse = '\n')
})
})`
It reads the s3 file correctly but does not update when the s3 file is changed. Assistance appreciated! Thanks :)