简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM