'Save file directly on AWS bucket

Actually, when the user upload a file, I make a copy on a temp folder and I sync this file with s3sync function (from the package aws.s3) to my AWS bucket. This is what I did :

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(aws.s3)


Sys.setenv(
  "AWS_ACCESS_KEY_ID" = "AAAA",
  "AWS_SECRET_ACCESS_KEY" = "BBBB",
  "AWS_DEFAULT_REGION" = "XXXX"
)

ui <- shinyUI(fluidPage(
  
  titlePanel("Testing File upload"),
  
  fileInput('file_input', 'upload file ( . pdf format only)', accept = c('.pdf'))
  
))

server <- shinyServer(function(input, output) {
  
  
  observe({
    req(input$file_input)
    temp = tempdir()
    file.copy(input$file_input, temp, overwrite = T)
    s3sync(path = temp, bucket = "galea", direction = "upload")
  })
  
  
  
})

shinyApp(ui = ui, server = server)

But I would like to save files directly on my AWS bucket when user upload a PDF file. How can we do that ?

Some help would be appreciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source