I have an RShiny app where I save images from an S3 bucket (after checking if they exist) and then render them using the following code. The ‘image1.jpeg’ in this example changes based on user input and gets overwritten quite a bit during the course of using the app. Instead of saving the image in order to render, I wanted to see if it was possible to just read into memory and render?
I know the aws.s3 package has an s3_readusing() function which I think I could utilize, but I am not sure how to tie this into renderImage() since the first parameter of the list (src) seems to require a path to an image?
Thank you in advance for any help!
Simplified Example Code:
# this is part of a larger observeEvent(), where image1.jpeg is changing based on user input
if(aws.s3::object_exists(key1, bucket = bucket_name) == TRUE){
aws.s3::save_object(key1, bucket_name, file = "images/image1.jpeg")
}
output$finalImage <- renderImage({
if(aws.s3::object_exists(key1, bucket_name) == TRUE){
list(src = './images/image1.jpeg',
contentType = 'image/jpeg',
width = "200", height = "200",
alt = "Screening")
}
}, deleteFile = FALSE)