-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy path03_publish_demo.Rmd
123 lines (93 loc) · 1.72 KB
/
03_publish_demo.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
title: "publish"
author: "Lucy D’Agostino McGowan"
date: "5/3/2017"
output:
github_document:
toc: true
---
```{r setup, include=FALSE}
library("googledrive")
library("googlesheets")
library("dplyr")
library("readr")
```
## Motivation
Push a table into a Sheet.
Try to read it _as another user_
Assume you even have the key.
You will fail.
Now, as the user who owns the Sheet, publish it.
Now, as the other user, try again to read it via googlesheets. You should succeed.
## Push a file into a Sheet
```{r}
drive_auth("drive-token.rds")
file <- drive_upload(
R.home('doc/BioC_mirrors.csv'),
type = "spreadsheet"
)
```
## Check publication status (should be FALSE)
```{r}
drive_show_publish(file)
```
## get URL
```{r}
url <- drive_share_link(file)
url
```
## it's published, not shared
```{r}
file
```
```{r}
key <- file$id
```
## switch to different account
```{r, eval = FALSE}
gs_auth("sheets-token.rds")
```
## this shouldn't work
```{r}
try(gs_url(url, visibility = "private", lookup = FALSE))
geterrmessage()
```
## publish it on Drive
```{r}
file <- drive_publish(file)
drive_show_publish(file)
```
## try again!
```{r}
gs_url(url, lookup = FALSE)
```
check again that the access - it is not shared, but it is published.
```{r}
promote(file, "shared")
```
## clean up
```{r}
drive_rm(file)
```
## Now let's try shared but not published
```{r}
file <- drive_upload(
R.home('doc/BioC_mirrors.csv'),
type = "spreadsheet"
)
```
```{r}
file <- drive_share(file, role = "reader", type = "anyone")
```
```{r}
url <- drive_share_link(file)
url
```
## this should work!
```{r}
gs_url(url, visibility = "private", lookup = FALSE)
```
It is not published, but it is shared.
```{r}
file <- drive_show_publish(file)
```