简体   繁体   English

如何在亚马逊网络服务上从Rstudio保存数据到S3

[英]How to save data to S3 from Rstudio on amazon web services

I am using Rstudio on Amazon Web Services 我在Amazon Web Services上使用Rstudio

I am storing files as part of the RStudio environment with the root of RStudio environment being called "~Home/Myproject" 我将文件存储为RStudio环境的一部分,其中RStudio环境的根被称为"~Home/Myproject"

I want to create a website in Rstudio using rmarkdown::render_site() . 我想使用rmarkdown::render_site()在Rstudio中创建一个网站。 This creates html from .Rmd in the folder that I run the command from. 这将从我运行命令的文件夹中的.Rmd创建html。

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. 因为我使用S3来托管我的网站,我希望将生成的文件传输到存储在S3的目录,但是a)我不知道如何获取目录路径和b)如何创建在R.转移

I am also trying something similar :) 我也尝试类似的东西:)

so far the best solution i have found is use of cloudyr 到目前为止,我发现的最佳解决方案是使用cloudyr

You can install the aws package only with the following 您只能使用以下内容安装aws软件包

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. 这是测试运行的非常简化的版本,当然,您肯定希望使用.Renviron来存储您的Sys.env数据,而不是将它们放在脚本本身中。 These details again you can find in here 您可以在此处找到这些细节

hope that helps. 希望有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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