Created
January 13, 2017 18:10
-
-
Save mwhitaker/7904d01f80703cd1b826507b19bc4c5a to your computer and use it in GitHub Desktop.
Use googleCloudStorageR to automatically upload to Cloud Storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Host image files on Google Cloud storage" | |
author: "Michael Whitaker" | |
date: "January 12, 2017" | |
output: | |
html_document: | |
self_contained: false | |
--- | |
```{r setup, include=FALSE} | |
library(knitr) | |
library(googleCloudStorageR) | |
opts_chunk$set(echo = TRUE) | |
opts_knit$set(upload.fun = function(file) { | |
upload_try <- gcs_upload(file, name = basename(file), predefinedAcl = "publicRead") | |
paste0("https://storage.googleapis.com/BUCKETNAME/",upload_try$name) | |
}) | |
``` | |
## R Markdown | |
The function in the above chunk uploads any generated images and adds the src URL automatically in the generated HTML file. Just change to your **BUCKETNAME** | |
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>. | |
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: | |
```{r cars} | |
plot(cars) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment