side note, really excited to include emojis in a non-hacky way, thanks emo::ji r emo::ji("sunflower")

library('googledrive')
library('dplyr')
drive_auth("drive-token.rds")

List

drive_list() pulls out name, type, & id

drive_list()

We can search using regular expressions

drive_list(pattern = "test")

We can also pass additional query parameters through the ..., for example

drive_list(pattern = "test", orderBy = "modifiedTime")

Metadata

Note: now it seems we have to specify the fields (in v2 where I was working previously, it would automatically output everything, see this).

List of all fields here.

Now let's say I want to dive deeper into the top one

id <- drive_list("test")$id[1]
file <- drive_file(id)
file

In addition to the things I've pulled out, there is a tibble of permissions as well as a list (now named kitchen_sink, this should change), that contains all output fields.

file$permissions
str(file$kitchen_sink)

User info

drive_user()

Upload file

write.table("this is a test", file = "~/desktop/test.txt")
drive_upload(from = "~/desktop/test.txt", up_name = "This is a test", overwrite = TRUE)
file <- drive_file(drive_list("This is a test")$id)
file

Update sharing

file <- drive_share(file, role = "writer", type = "user", emailAddress = "dagostino.mcgowan.stats@gmail.com",emailMessage = "I am sharing this cool file with you. Now you can write. You are welcome." )

View permissions

file$permissions %>%
  select(displayName,role, type)

Make it fully shareable

file <- drive_share(file, role = "reader", type = "anyone", allowFileDiscovery = "true")

Extract share link

drive_share_link(file)

this looks exactly the same as the share link from the Google Drive GUI except usp=drivesdk instead of usp=sharing

Delete file

drive_delete(file)


tidyverse/googledrive documentation built on Jan. 14, 2024, 3:44 a.m.