Sebastian Zeki
Sebastian Zeki

Reputation: 6874

How to save data to S3 from Rstudio on amazon web services

I am using Rstudio on Amazon Web Services

I am storing files as part of the RStudio environment with the root of RStudio environment being called "~Home/Myproject"

I want to create a website in Rstudio using rmarkdown::render_site(). This creates html from .Rmd in the folder that I run the command from.

Because I use S3 to host my website I would love for the generated files to be transferred to the directory this is stored in, on S3 but a) I don't know how to get the directory path and b) how can I create the transfer in R.

Upvotes: 1

Views: 2454

Answers (1)

gmpc
gmpc

Reputation: 86

I am also trying something similar :)

so far the best solution i have found is use of cloudyr

You can install the aws package only with the following

install.packages("awspack", repos = c(cloudyr = "http://cloudyr.github.io/drat", getOption("repos")))

After that all you need is

Sys.setenv(AWS_ACCESS_KEY_ID = "XXXXXXXXXXX",
       AWS_SECRET_ACCESS_KEY = "XXXXXXXXXXXXXXXXXXX")

library("aws.s3")

put_object(file = "YourFileName", object = "TheObjectNameInsideS3", bucket = "YourBucketName")

This is very simplified version for test run of course, and you would definitely like to use .Renviron to store your Sys.env data and not put them in script itself. These details again you can find in here

hope that helps.

Upvotes: 4

Related Questions