Google Drive
Google Drive
Google Drive
URL http://googledrive.tidyverse.org,
https://github.com/tidyverse/googledrive
BugReports https://github.com/tidyverse/googledrive/issues
VignetteBuilder knitr
RoxygenNote 6.0.1
NeedsCompilation no
Author Lucy D'Agostino McGowan [aut],
Jennifer Bryan [aut, cre],
RStudio [cph, fnd]
Maintainer Jennifer Bryan <jenny@rstudio.com>
Repository CRAN
Date/Publication 2017-08-28 21:57:16 UTC
R topics documented:
as_dribble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
as_id . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
as_team_drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
dribble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1
2 R topics documented:
dribble-checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
drive_about . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
drive_api_key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
drive_auth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
drive_auth_config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
drive_browse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
drive_cp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
drive_deauth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
drive_download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
drive_empty_trash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
drive_endpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
drive_example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
drive_extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
drive_fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
drive_find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
drive_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
drive_link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
drive_ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
drive_mime_type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
drive_mkdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
drive_mv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
drive_publish . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
drive_rename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
drive_reveal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
drive_rm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
drive_share . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
drive_token . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
drive_trash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
drive_update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
drive_upload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
drive_user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
generate_request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
googledrive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
make_request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
process_response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
team_drives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
team_drive_create . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
team_drive_find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
team_drive_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
team_drive_rm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
team_drive_update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Index 53
as_dribble 3
Description
Converts various representations of Google Drive files into a dribble, the object used by googledrive
to hold Drive file metadata. Files can be specified via
Usage
as_dribble(x, ...)
Arguments
x A vector of Drive file paths, a vector of file ids marked with as_id(), a list of
Files Resource objects, or a suitable data frame.
... Other arguments passed down to methods. (Not used.)
Examples
## Not run:
## specify the path
as_dribble("abc")
as_dribble("abc/def")
## End(Not run)
4 as_id
Description
Gets file ids from various inputs and marks them as such, to distinguish them from file names or
paths.
This is a generic function.
Usage
as_id(x, ...)
Arguments
Value
Examples
as_id("123abc")
as_id("https://docs.google.com/spreadsheets/d/qawsedrf16273849/edit#gid=12345")
## Not run:
x <- drive_find(n_max = 3)
as_id(x)
x <- drive_get("foofy")
as_id(x)
x <- team_drive_find("work-stuff")
as_id(x)
## End(Not run)
as_team_drive 5
Description
Converts various representations of Team Drive into a dribble, the object used by googledrive to
hold Drive file metadata. Team Drives can be specified via
• Name.
• Team Drive id. Mark with as_id() to distinguish from name.
• Data frame or dribble consisting solely of Team Drives.
• List representing Team Drive resource objects. Mostly for internal use.
Note: Team Drives are only available to users of certain enhanced Google services, such as G Suite
Enterprise, G Suite Business, or G Suite for Education.
This is a generic function.
Usage
as_team_drive(x, ...)
Arguments
x A vector of Team Drive names, a vector of Team Drive ids marked with as_id(),
a list of Team Drive Resource objects, or a suitable data frame.
... Other arguments passed down to methods. (Not used.)
Examples
## Not run:
## specify the name
as_team_drive("abc")
## End(Not run)
6 dribble-checks
Description
googledrive stores the metadata for one or more Drive files or Team Drives as a dribble. It is a
"Drive tibble" with one row per file or Team Drive and, at a minimum, these variables:
The dribble format is handy because it exposes the file name, which is good for humans, but keeps
it bundled with the file’s unique id and other metadata, which are needed for API calls.
In general, the dribble class will be retained even after subsetting, as long as the required variables
are present and of the correct type.
See Also
as_dribble()
Description
Sometimes you need to check things about a dribble‘ or about the files it represents, such as:
• Is it even a dribble?
• Size: Does the dribble hold exactly one file? At least one file? No file?
• File type: Is this file a folder?
• File ownership and access: Is it mine? Published? Shared?
Usage
is_dribble(d)
no_file(d)
single_file(d)
some_files(d)
drive_about 7
confirm_dribble(d)
confirm_single_file(d)
confirm_some_files(d)
is_folder(d)
is_native(d)
is_parental(d)
is_mine(d)
is_team_drive(d)
is_team_drivy(d)
Arguments
d A dribble.
Examples
## Not run:
## most of us have multiple files or folders on Google Drive
d <- drive_find()
is_dribble(d)
no_file(d)
single_file(d)
some_files(d)
confirm_single_file(d)
confirm_some_files(d)
is_folder(d)
is_mine(d)
## End(Not run)
Description
Gets information about the user, the user’s Drive, and system capabilities. This function mostly
exists to power drive_user(), which extracts the most useful information (the information on
current user) and prints it nicely.
8 drive_api_key
Usage
drive_about()
Value
See Also
• https://developers.google.com/drive/v3/reference/about/get
Examples
## Not run:
drive_about()
## End(Not run)
Description
Retrieves the pre-configured API key. Learn more in Google’s document Credentials, access, secu-
rity, and identity. By default, this API key is initialized to one that ships with googledrive. But the
user can store their own key via drive_auth_config(), i.e. overwrite the default.
Usage
drive_api_key()
Value
Examples
drive_api_key()
## Not run:
drive_auth_config(api_key = "123")
drive_api_key()
## End(Not run)
Description
Authorize googledrive to view and manage your Drive files. By default, you are directed to a web
browser, asked to sign in to your Google account, and to grant googledrive (the tidyverse, actually)
permission to operate on your behalf with Google Drive. By default, these user credentials are
cached in a file named .httr-oauth in the current working directory, from where they can be
automatically refreshed, as necessary.
Usage
Arguments
oauth_token Optional; path to an .rds file with a previously stored OAuth token.
service_token Optional; a JSON string, URL, or path, giving or pointing to the service token
file.
reset Logical, defaults to FALSE. Set to TRUE if you want to forget any token previously
used in this session and start afresh. Disables the .httr-oauth file in current
working directory by renaming to .httr-oauth-SUSPENDED.
cache A logical value or a string. TRUE means to cache using the default cache file
.httr-oauth, FALSE means don’t cache, and NA means to guess using some
sensible heuristics. A string mean use the specified path as the cache file.
use_oob if FALSE, use a local webserver for the OAuth dance. Otherwise, provide
a URL to the user and prompt for a validation code. Defaults to the of the
"httr_oob_default" default, or TRUE if httpuv is not installed.
verbose Logical, indicating whether to print informative messages (default TRUE).
10 drive_auth_config
Details
Most users, most of the time, do not need to call drive_auth() explicitly – it is triggered by the
first action that requires authorization. Even when called, the default arguments will often suffice.
However, when necessary, this function allows the user to
For even deeper control over auth, use drive_auth_config() to use your own OAuth app or API
key. drive_auth_config() also allows you to deactivate auth, sending only an API key in requests,
which works if you only need to access public data.
See Also
More detail is available from Using OAuth 2.0 for Installed Applications
Other auth functions: drive_auth_config, drive_deauth
Examples
## Not run:
## load/refresh existing credentials, if available
## otherwise, go to browser for authentication and authorization
drive_auth()
## End(Not run)
Description
This function gives advanced users more control over auth. Whereas drive_auth() gives control
over tokens, drive_auth_config() gives control of:
• The googledrive auth state. The default is active, meaning all requests are sent with a token
and, if one is not already loaded, OAuth flow is initiated. It is possible, however, to place
unauthorized requests to the Drive API, as long as you are accessing public resources. Set
active to FALSE to enter this state and never send a token.
• The OAuth app. If you want to use your own app, setup a new project in Google Developers
Console. Follow the instructions in OAuth 2.0 for Mobile & Desktop Apps to obtain your own
client ID and secret. Provide these to httr::oauth_app().
• The API key. If googledrive auth is deactivated (see above), all requests will be sent with an
API key. If you want to provide your own, setup a project as described above and follow the
instructions in Setting up API keys.
Usage
Arguments
active Logical. TRUE means a token will be sent. FALSE means it will not.
app OAuth app. Defaults to a tidyverse app that ships with googledrive.
api_key API key. Defaults to a key that ships with googledrive. Necessary in order to
make unauthorized "token-free" requests for public resources.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
See Also
Examples
drive_auth_config()
12 drive_cp
Description
Visits a file on Google Drive in your default browser.
Usage
drive_browse(file = .Last.value)
Arguments
file Something that identifies the file of interest on your Google Drive. Can be a
name or path, a file id or URL marked with as_id(), or a dribble.
Value
Character vector of file hyperlinks, from drive_link(), invisibly.
Examples
## Not run:
drive_find(n_max = 1) %>% drive_browse()
## End(Not run)
Description
Copies an existing Drive file into a new file id.
Usage
drive_cp(file, path = NULL, name = NULL, ..., verbose = TRUE)
Arguments
file Something that identifies the file of interest on your Google Drive. Can be a
name or path, a file id or URL marked with as_id(), or a dribble.
path Specifies target destination for the new file on Google Drive. Can be an actual
path (character), a file id marked with as_id(), or a dribble. If specified as an
actual path, it is best to explicitly indicate if it’s a folder by including a trailing
slash, since it cannot always be worked out from the context of the call. Defaults
to "Copy of FILE-NAME".
drive_cp 13
name Character, new file name if not specified as part of path. This will force path to
be treated as a folder, even if it is character and lacks a trailing slash. Defaults
to "Copy of FILE-NAME".
... Named parameters to pass along to the Drive API. You can affect the metadata
of the target file by specifying properties of the Files resource via .... See the
"Request body" section of the Drive API docs for the associated endpoint.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
See Also
Wraps the files.copy endpoint:
• https://developers.google.com/drive/v3/reference/files/copy
Examples
## Not run:
## Create a file to copy
file <- drive_upload(drive_example("chicken.txt"), "chicken-cp.txt")
csv_file,
name = "chicken-cp",
mime_type = drive_mime_type("spreadsheet")
)
## clean up
drive_rm(csv_file, chicken_sheet)
## End(Not run)
Description
Suspend googledrive’s authorization to place requests to the Drive API on behalf of the authenti-
cated user.
Usage
Arguments
clear_cache logical indicating whether to disable the .httr-oauth file in working directory,
if such exists, by renaming to .httr-oauth-SUSPENDED
verbose Logical, indicating whether to print informative messages (default TRUE).
See Also
Examples
## Not run:
drive_deauth()
## End(Not run)
drive_download 15
Description
This function downloads a file from Google Drive. Native Google file types, such as Google Docs,
Google Sheets, and Google Slides, must be exported to a conventional local file type. This can be
specified:
• explicitly via type
• implicitly via the file extension of path
• not at all, i.e. rely on default built into googledrive
To see what export file types are even possible, see the Drive API documentation. Returned dribble
contains local path to downloaded file in local_path.
Usage
drive_download(file, path = NULL, type = NULL, overwrite = FALSE,
verbose = TRUE)
Arguments
file Something that identifies the file of interest on your Google Drive. Can be a
name or path, a file id or URL marked with as_id(), or a dribble.
path Character. Path for output file. If absent, the default file name is the file’s name
on Google Drive and the default location is working directory, possibly with an
added file extension.
type Character. Only consulted if file is a native Google file. Specifies the desired
type of the downloaded file. Will be processed via drive_mime_type(), so
either a file extension like "pdf" or a full MIME type like "application/pdf"
is acceptable.
overwrite A logical scalar. If path already exists, do you want to overwrite it?
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
Examples
## Not run:
## Upload a csv file into a Google Sheet
file <- drive_upload(
drive_example("chicken.csv"),
type = "spreadsheet"
)
16 drive_endpoints
## Clean up
unlink(c("chicken.csv", "chicken.csv.xlsx", "my_csv_file.csv"))
drive_rm(file)
## End(Not run)
Description
Caution, this will permanently delete files in your Drive trash.
Usage
drive_empty_trash(verbose = TRUE)
Arguments
verbose Logical, indicating whether to print informative messages (default TRUE).
Description
Returns a list of selected Drive API v3 endpoints, as stored inside the googledrive package. The
names of this list (or the id sub-elements) are the nicknames that can be used to specify an endpoint
in generate_request(). For each endpoint, we store its nickname or id, the associated HTTP
verb, the path, and details about the parameters. This list is derived programmatically from the
Drive API v3 Discovery Document.
Usage
drive_endpoints(i = NULL)
drive_example 17
Arguments
Value
A list containing some or all of the subset of the Drive API v3 endpoints that are used internally by
googledrive.
Examples
str(drive_endpoints(), max.level = 2)
drive_endpoints("drive.files.delete")
drive_endpoints(4)
Description
googledrive comes bundled with a few small files to use in examples. This function make them easy
to access.
Usage
drive_example(path = NULL)
Arguments
Examples
drive_example()
drive_example("chicken.jpg")
18 drive_fields
Description
This is a helper to determinine which extension should be used for a file. Two types of input are
acceptable:
Usage
drive_extension(type = NULL)
Arguments
type Character. MIME type or file extension.
Value
Character. File extension.
Examples
## it's vectorized
drive_extension(c("text/plain", "pdf", "image/gif"))
Description
You may be able to improve the performance of your API calls by requesting only the metadata
that you actually need. This function is primarily for internal use and is currently focused on the
Files resource. Note that high-level googledrive functions assume that the name, id, and kind
fields are included, at a bare minimum. Assuming that resource = "files" (the default), input
provided via fields is checked for validity against the known field names and the validated fields
are returned. To see a tibble containing all possible fields and a short description of each, call
drive_fields(expose()).
prep_fields() prepares fields for inclusion as query parameters.
drive_find 19
Usage
drive_fields(fields = NULL, resource = "files")
Arguments
fields Character vector of field names. If resource = "files", they are checked for
validity. Otherwise, they are passed through.
resource Character, naming the API resource of interest. Currently, only the Files re-
source is anticipated.
Value
drive_fields(): Character vector of field names. prep_fields(): a string.
See Also
Working with partial resources, in the Drive API documentation.
Examples
## get a tibble of all fields for the Files resource + indicator of defaults
drive_fields(expose())
Description
This is the closest googledrive function to what you can do at https://drive.google.com: by
default, you just get a listing of your files. You can also search in various ways, e.g., filter by file
type or ownership or even work with Team Drive files, if you have access. This is a very powerful
function. Together with the more specific drive_get(), this is the main way to identify files to
target for downstream work.
Note: Team Drives are only available to users of certain enhanced Google services, such as G Suite
Enterprise, G Suite Business, or G Suite for Education.
Usage
drive_find(pattern = NULL, trashed = FALSE, type = NULL, n_max = Inf,
team_drive = NULL, corpus = NULL, ..., verbose = TRUE)
20 drive_find
Arguments
pattern Character. If provided, only the items whose names match this regular expres-
sion are returned. This is implemented locally on the results returned by the
API.
trashed Logical. Whether to search files that are not in the trash (the default), only files
that are in the trash (trashed = TRUE), or to search regardless of trashed status
(trashed = NA).
type Character. If provided, only files of this type will be returned. Can be any-
thing that drive_mime_type() knows how to handle. This is processed by
googledrive and sent as a query parameter.
n_max Integer. An upper bound on the number of items to return. This applies to the
results requested from the API, which may be further filtered locally, via the
pattern argument.
team_drive Anything that identifies one specific Team Drive: its name, its id or URL marked
with as_id(), or a dribble. Is pre-processed with as_team_drive(). Read
more about Team Drives.
corpus Character, specifying the search collection. Only relevant in the Team Drives
context. If specified, must be one of "user", "all", or "domain". Read more
about Team Drives.
... Other parameters to pass along in the request. The most likely candidate is q.
See below and the API’s Search for Files guide.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
File type
The type argument is pre-processed with drive_mime_type(), so you can use a few shortcuts and
file extensions, in addition to full-blown MIME types. googledrive forms a search clause to pass to
q.
Search parameters
Do advanced search on file properties by providing search clauses to the q parameter that is passed
to the API via .... Multiple q clauses or vector-valued q are combined via ’and’.
Trash
By default, drive_find() sets trashed = FALSE and does not include files in the trash. Literally,
it adds q = "trashed = false" to the query. To search only the trash, set trashed = TRUE. To see
files regardless of trash status, set trashed = NA, which adds q = "(trashed = true or trashed = false)"
to the query.
drive_find 21
Team Drives
If you have access to Team Drives, you’ll know. Use team_drive or corpus to search one or more
Team Drives or a domain. See Access Team Drives for more.
See Also
Wraps the files.list endpoint:
• https://developers.google.com/drive/v3/reference/files/list
Helpful resource for forming your own queries:
• https://developers.google.com/drive/v3/web/search-parameters
Examples
## Not run:
## list "My Drive" w/o regard for folder hierarchy
drive_find()
## filter for folders, the easy way and the hard way
drive_find(type = "folder")
drive_find(q = "mimeType = 'application/vnd.google-apps.folder'")
## filter for Google Sheets, the easy way and the hard way
drive_find(type = "spreadsheet")
drive_find(q = "mimeType='application/vnd.google-apps.spreadsheet'")
## End(Not run)
Description
Retrieve metadata for files specified via path or via file id.
If the files are specified via path, the returned dribble will include a path variable. To add path in-
formation to any dribble that lacks it, use drive_reveal(), e.g., drive_reveal(d, "path"). If
you want to list the contents of a folder, use drive_ls(). For general searching, use drive_find().
Note: Team Drives are only available to users of certain enhanced Google services, such as G Suite
Enterprise, G Suite Business, or G Suite for Education.
Usage
Arguments
path Character vector of path(s) to get. Use a trailing slash to indicate explicitly that
a path is a folder, which can disambiguate if there is a file of the same name (yes
this is possible on Drive!). A character vector marked with as_id() is treated
as if it was provided via the id argument.
id Character vector of Drive file ids or URLs (it is first processed with as_id()).
If both path and id are non-NULL, id is silently ignored.
team_drive Anything that identifies one specific Team Drive: its name, its id or URL marked
with as_id(), or a dribble. Is pre-processed with as_team_drive(). Read
more about Team Drives.
corpus Character, specifying the search collection. Only relevant in the Team Drives
context. If specified, must be one of "user", "all", or "domain". Read more
about Team Drives.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
• File and folder names need not be unique, even at a given level of the hierarchy. A single
name or file path can be associated with multiple files (or zero or exactly one).
• A file can have more than one direct parent. This implies that a single file can be represented
by multiple paths.
Bottom line: Do not assume there is a one-to-one relationship between file name or path and a Drive
file or folder. This implies the length of the input (i.e. the number of input paths or the number of
rows in a dribble) will not necessarily equal the number rows in the output.
See Also
Wraps the files.get endpoint and, if you specify files by name or path, also calls files.list:
• https://developers.google.com/drive/v3/reference/files/update
• https://developers.google.com/drive/v3/reference/files/list
Examples
## Not run:
## get info about your "My Drive" root folder
drive_get("~/")
## the API reserves the file id "root" for your root folder
drive_get(id = "root")
drive_get(id = "root") %>% drive_reveal("path")
## multiple names
drive_get(c("abc", "def"))
## search all Team Drives and other files user has accessed
drive_get(c("this.jpg", "that-file"), corpus = "all")
## End(Not run)
24 drive_ls
Description
Returns the "webViewLink" for one or more files, which is the "link for opening the file in a relevant
Google editor or viewer in a browser".
Usage
drive_link(file)
Arguments
file Something that identifies the file of interest on your Google Drive. Can be a
name or path, a file id or URL marked with as_id(), or a dribble.
Value
Character vector of file hyperlinks.
Examples
## Not run:
## get a few files into a dribble
three_files <- drive_find(n_max = 3)
## End(Not run)
Description
List the contents of a folder or Team Drive, recursively or not. This is a thin wrapper around
drive_find(), that simply adds one constraint: the search is limited to direct or indirect children
of path.
Usage
drive_ls(path = NULL, ..., recursive = FALSE)
drive_mime_type 25
Arguments
path Specifies a single folder on Google Drive whose contents you want to list. Can
be an actual path (character), a file id or URL marked with as_id(), or a
dribble. If it is a Team Drive or is a folder on a Team Drive, it must be passed
as a dribble.
... Any parameters that are valid for drive_find().
recursive Logical, indicating if you want only direct children of path (recursive = FALSE,
the default) or all children, including indirect (recursive = TRUE).
Value
An object of class dribble, a tibble with one row per item.
Examples
## Not run:
## get contents of the folder 'abc' (non-recursive)
drive_ls("abc")
## get contents of folder 'abc' whose names contain the letters 'def'
drive_ls(path = "abc", pattern = "def")
## get all the files below 'abc', recursively, that are starred
drive_ls(path = "abc", q = "starred = true", recursive = TRUE)
## End(Not run)
Description
This is a helper to determine which MIME type should be used for a file. Three types of input are
acceptable:
• Native Google Drive file types. Important examples:
– "document" for Google Docs
– "folder" for folders
– "presentation" for Google Slides
– "spreadsheet" for Google Sheets
• File extensions, such as "pdf", "csv", etc.
• MIME types accepted by Google Drive (these are simply passed through).
26 drive_mkdir
Usage
drive_mime_type(type = NULL)
Arguments
type Character. Google Drive file type, file extension, or MIME type. Pass the sen-
tinel expose() if you want to get the full table used for validation and lookup,
i.e. all MIME types known to be relevant to the Drive API.
Value
Character. MIME type.
Examples
## get the mime type for Google Spreadsheets
drive_mime_type("spreadsheet")
## it's vectorized
drive_mime_type(c("presentation", "pdf", "image/gif"))
## see the internal tibble of MIME types known to the Drive API
drive_mime_type(expose())
Description
Creates a new Drive folder. To update the metadata of an existing Drive file, including a folder, use
drive_update().
Usage
drive_mkdir(name, parent = NULL, ..., verbose = TRUE)
Arguments
name Name for the new folder or, optionally, a path that specifies an existing parent
folder, as well as the new name.
parent Target destination for the new folder, i.e. a folder or a Team Drive. Can be
given as an actual path (character), a file id or URL marked with as_id(), or a
dribble. Defaults to your "My Drive" root folder.
drive_mv 27
... Named parameters to pass along to the Drive API. You can affect the metadata
of the target file by specifying properties of the Files resource via .... See the
"Request body" section of the Drive API docs for the associated endpoint.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
See Also
Wraps the files.create endpoint:
• https://developers.google.com/drive/v3/reference/files/create
Examples
## Not run:
## Create folder named 'ghi', then another below named it 'jkl' and star it
ghi <- drive_mkdir("ghi")
jkl <- drive_mkdir("ghi/jkl", starred = TRUE)
## clean up
drive_rm(ghi)
## End(Not run)
Description
Move a Drive file to a different folder, give it a different name, or both. Note that folders on Google
Drive are not like folders on your local filesystem. They are more like a label, which implies that
a Drive file can have multiple folders as direct parent! However, most people still use and think of
them like "regular" folders. When we say "move a Drive file", it actually means: "add a new folder
to this file’s parents and remove the old one".
28 drive_mv
Usage
drive_mv(file, path = NULL, name = NULL, verbose = TRUE)
Arguments
file Something that identifies the file of interest on your Google Drive. Can be a
name or path, a file id or URL marked with as_id(), or a dribble.
path Specifies target destination for the new file on Google Drive. Can be an actual
path (character), a file id marked with as_id(), or a dribble. If specified as an
actual path, it is best to explicitly indicate if it’s a folder by including a trailing
slash, since it cannot always be worked out from the context of the call. Defaults
to current name.
name Character, new file name if not specified as part of path. This will force path to
be treated as a folder, even if it is character and lacks a trailing slash. Defaults
to current name.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
Examples
## Not run:
## create a file to move
file <- drive_upload(drive_example("chicken.txt"), "chicken-mv.txt")
## rename it, but leave in current folder (root folder, in this case)
file <- drive_mv(file, "chicken-mv-renamed.txt")
## move it again
## specify destination as path with trailing slash
## to ensure we get a move vs. renaming it to "mv-folder"
file <- drive_mv(file, "mv-folder/")
## Clean up
drive_rm(file, folder)
drive_publish 29
## End(Not run)
Description
Publish (or un-publish) native Google files to the web. Native Google files include Google Docs,
Google Sheets, and Google Slides. The returned dribble will have extra columns, published and
revisions_resource. Read more in drive_reveal().
Usage
drive_publish(file, ..., verbose = TRUE)
Arguments
file Something that identifies the file(s) of interest on your Google Drive. Can be a
character vector of names/paths, a character vector of file ids or URLs marked
with as_id(), or a dribble.
... Name-value pairs to add to the API request body (see API docs linked below
for details). For drive_publish(), we include publishAuto = TRUE and
publishedOutsideDomain = TRUE, if user does not specify other values.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
See Also
Wraps the revisions.update endpoint:
• https://developers.google.com/drive/v3/reference/revisions/update
Examples
## Not run:
## Upload file to publish
file <- drive_upload(
drive_example("chicken.csv"),
type = "spreadsheet"
)
## Publish file
30 drive_rename
## Unpublish file
file <- drive_unpublish(file)
file$published
## Clean up
drive_rm(file)
## End(Not run)
Description
This is a wrapper for drive_mv() that only renames a file. If you would like to rename AND move
the file, see drive_mv().
Usage
drive_rename(file, name = NULL, verbose = TRUE)
Arguments
file Something that identifies the file of interest on your Google Drive. Can be a
name or path, a file id or URL marked with as_id(), or a dribble.
name Character. Name you would like the file to have.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
Examples
## Not run:
## Create a folder to rename
folder <- drive_mkdir("folder-to-rename")
## Rename folder
folder <- folder %>%
drive_rename(name = "renamed-folder")
## Clean up
drive_rm(folder)
## End(Not run)
drive_reveal 31
Description
drive_reveal() adds extra information about your Drive files that is not automatically present in
the default dribble produced by googledrive. Why is this info not always present?
1. You don’t always care about it.
2. It may require calling different endpoints in the Drive API. Example: getting a file’s permis-
sions.
3. It might require additional API calls. Example: figuring out the path(s) associated with a
specific file.
Usage
drive_reveal(file, what = c("path", "trashed", "mime_type", "permissions",
"published"))
Arguments
file Something that identifies the file(s) of interest on your Google Drive. Can be a
character vector of names/paths, a character vector of file ids or URLs marked
with as_id(), or a dribble.
what Character, describing the type of info you want to add:
• path. Warning: this can be slow, especially if called on many files.
• trashed
• mime_type
• permissions. Who is this file shared with and in which roles?
• published
Value
An object of class dribble, a tibble with one row per item.
Trashed
When what = "trashed", the dribble gains a logical variable that indicates whether a file is in
the trash..
MIME type
When what = "mime_type", the dribble gains a variable of MIME types.
Permissions
When what = "permissions" the dribble gains a logical variable shared that indicates whether
a file is shared and a new list-column permissions_resource containing lists of Permissions re-
sources.
Publishing
When what = "published" the dribble gains a logical variable published that indicates whether
a file is published and a new list-column revision_resource containing lists of Revisions re-
sources.
Examples
## Not run:
## Get a nice, random selection of files
files <- drive_find(n_max = 10, trashed = NA)
## Reveal
## * paths (warning: can be slow for many files!)
## * if `trashed` or not
## * MIME type
## * permissions, i.e. sharing status
## * if `published` or not
drive_reveal(files, "path")
drive_reveal(files, "trashed")
drive_reveal(files, "mime_type")
drive_reveal(files, "permissions")
drive_reveal(files, "published")
## End(Not run)
Description
Caution: this will permanently delete your files! For a safer, reversible option, see drive_trash().
drive_share 33
Usage
drive_rm(..., verbose = TRUE)
Arguments
... One or more Drive files, specified in any valid way, i.e. as a dribble, by name
or path, or by file id or URL marked with as_id(). Or any combination thereof.
Elements are processed with as_dribble() and row-bound prior to deletion.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
Logical vector, indicating whether the delete succeeded.
See Also
Wraps the files.delete endpoint:
• https://developers.google.com/drive/v3/reference/files/delete
Examples
## Not run:
## Create something to remove
drive_upload(drive_example("chicken.txt"), name = "chicken-rm.txt")
## Remove it by name
drive_rm("chicken-rm.txt")
## End(Not run)
Description
Grant individuals or other groups access to files, including permission to read, comment, or edit.
The returned dribble will have extra columns, shared and permissions_resource. Read more
in drive_reveal().
34 drive_share
Usage
drive_share(file, role = c("reader", "commenter", "writer", "owner",
"organizer"), type = c("user", "group", "domain", "anyone"), ...,
verbose = TRUE)
Arguments
file Something that identifies the file(s) of interest on your Google Drive. Can be a
character vector of names/paths, a character vector of file ids or URLs marked
with as_id(), or a dribble.
role Character. The role to grant. Must be one of:
• organizer (applies only to Team Drives)
• owner
• writer
• commenter
• reader
type Character. Describes the grantee. Must be one of:
• user
• group
• domain
• anyone
... Name-value pairs to add to the API request. This is where you provide addi-
tional information, such as the emailAddress (when grantee type is "group"
or "user") or the domain (when grantee type is "domain"). Read the API docs
linked below for more details.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
See Also
Wraps the permissions.update endpoint:
• https://developers.google.com/drive/v3/reference/permissions/create
Examples
## Not run:
## Upload a file to share
file <- drive_upload(
drive_example("chicken.txt"),
name = "chicken-share.txt",
type = "document"
)
drive_token 35
## Let a different specific person edit and customize the email notification
file <- file %>%
drive_share(
role = "writer",
type = "user",
emailAddress = "carol@example.com",
emailMessage = "Would appreciate your feedback on this!"
)
## Clean up
drive_rm(file)
## End(Not run)
Description
For internal use or for those programming around the Drive API. Produces a token prepared for use
with generate_request() and build_request(). Most users do not need to handle tokens "by
hand" or, even if they need some control, drive_auth() is what they need. If there is no current
token, drive_auth() is called to either load from cache or initiate OAuth2.0 flow. If auth has been
deactivated via drive_auth_config(), drive_token() returns NULL.
Usage
drive_token(verbose = FALSE)
Arguments
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
a request object (an S3 class provided by httr)
36 drive_trash
See Also
Other low-level API functions: generate_request, make_request, process_response
Examples
## Not run:
req <- generate_request(
"drive.files.get",
list(fileId = "abc"),
token = drive_token()
)
req
## End(Not run)
Description
Move Drive files to or from trash
Usage
drive_trash(file, verbose = TRUE)
Arguments
file Something that identifies the file(s) of interest on your Google Drive. Can be a
character vector of names/paths, a character vector of file ids or URLs marked
with as_id(), or a dribble.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
Examples
## Not run:
## Create a file and put it in the trash.
file <- drive_upload(drive_example("chicken.txt"), "chicken-trash.txt")
drive_trash("chicken-trash.txt")
## Clean up
drive_rm("chicken-trash.txt")
## End(Not run)
Description
Update an existing Drive file id with new content ("media" in Drive API-speak), new metadata, or
both.
Usage
drive_update(file, media = NULL, ..., verbose = TRUE)
Arguments
file Something that identifies the file of interest on your Google Drive. Can be a
name or path, a file id or URL marked with as_id(), or a dribble.
media Character, path to the local file to upload.
... Named parameters to pass along to the Drive API. You can affect the metadata
of the target file by specifying properties of the Files resource via .... See the
"Request body" section of the Drive API docs for the associated endpoint.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
See Also
Wraps the files.update endpoint:
• https://developers.google.com/drive/v3/reference/files/update
• https://developers.google.com/drive/v3/web/manage-uploads
38 drive_upload
Examples
## Not run:
## Create a new file, so we can update it
x <- drive_upload(drive_example("chicken.csv"))
## Clean up
drive_rm(x, folder)
## End(Not run)
Description
Uploads a local file into a new Drive file. To update the content or metadata of an existing Drive
file, use drive_update().
Usage
drive_upload(media, path = NULL, name = NULL, type = NULL, ...,
verbose = TRUE)
Arguments
media Character, path to the local file to upload.
drive_upload 39
path Specifies target destination for the new file on Google Drive. Can be an actual
path (character), a file id marked with as_id(), or a dribble. If specified as an
actual path, it is best to explicitly indicate if it’s a folder by including a trailing
slash, since it cannot always be worked out from the context of the call. Will
default to its local name.
name Character, new file name if not specified as part of path. This will force path
to be treated as a folder, even if it is character and lacks a trailing slash. Will
default to its local name.
type Character. If type = NULL, a MIME type is automatically determined from
the file extension, if possible. If the source file is of a suitable type, you can
request conversion to Google Doc, Sheet or Slides by setting type to document,
spreadsheet, or presentation, respectively. All non-NULL values for type
are pre-processed with drive_mime_type().
... Named parameters to pass along to the Drive API. You can affect the metadata
of the target file by specifying properties of the Files resource via .... See the
"Request body" section of the Drive API docs for the associated endpoint.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
See Also
Wraps the files.create endpoint:
• https://developers.google.com/drive/v3/reference/files/create
• https://developers.google.com/drive/v3/web/manage-uploads#importing_to_google_
docs_types_wzxhzdk18wzxhzdk19
Examples
## Not run:
## upload a csv file
chicken_csv <- drive_upload(
drive_example("chicken.csv"),
"chicken-upload.csv"
)
drive_browse(chicken_sheet)
## clean-up
drive_find("chicken.*upload") %>% drive_rm()
## Clean up
drive_rm(chicken)
## End(Not run)
Description
Reveals information about the user associated with the current token. This is a thin wrapper around
drive_about() that just extracts the most useful information (the information on current user) and
prints it nicely.
Usage
drive_user(verbose = TRUE)
Arguments
Value
See Also
• https://developers.google.com/drive/v3/reference/about/get
generate_request 41
Examples
## Not run:
drive_user()
## End(Not run)
Description
Build a request, using some knowledge of the Drive v3 API. Most users should, instead, use higher-
level wrappers that facilitate common tasks, such as uploading or downloading Drive files. The
functions here are intended for internal use and for programming around the Drive API.
Usage
generate_request(endpoint = character(), params = list(), key = NULL,
token = drive_token())
Arguments
endpoint Character. Nickname for one of the selected Drive v3 API endpoints built into
googledrive. Learn more in drive_endpoints().
params Named list. Parameters destined for endpoint URL substitution, the query, or,
for generate_request() only, the body.
key API key. Will be needed for requests that don’t contain a token. The need
for an API key in the absence of a token is explained in Google’s document
Credentials, access, security, and identity. In order of precedence, these sources
are consulted: the formal key argument, a key parameter in params, a pre-
configured API key fetched via drive_api_key(). googledrive ships with a
built-in key or users can override with their own via drive_auth_config().
token Drive token. Set to NULL to suppress the inclusion of a token. Note that, if auth
has been de-activated via drive_auth_config(), drive_token() will actually
return NULL.
path Character, e.g., "drive/v3/files/{fileId}". It can include variables inside
curly brackets, as the example does, which are substituted using named param-
eters found in the params argument.
method Character, should match an HTTP verb, e.g., GET, POST, PATCH or PUT
body List, values to pass to the API request body.
42 generate_request
Details
There are two functions:
• generate_request() lets you provide the bare minimum of input. It takes a nickname for an
endpoint and:
– Uses the API spec to look up the path and method.
– Checks params for validity and completeness with respect to the endpoint. Separates
body parameters from those destined for path substitution or the query.
– Adds an API key to the query if token = NULL. Or, at least, we try.
– Adds supportsTeamDrives = TRUE to the query if the endpoint requires.
• build_request() builds a request from explicit parts. It is quite dumb, only doing URL
endpoint substitution and URL formation. It’s up to the caller to make sure the path, method,
params, body, and token are valid. Use this to call a Drive API endpoint that doesn’t appear
in the list returned by drive_endpoints().
Value
list()
Components are method, path, query, body, token, and url, suitable as input for make_request().
The path is post-substitution and the query is a named list of all the non-body params that were
not used during this substitution. url is the full URL after prepending the base URL for the Drive
v3 API and appending the query.
See Also
Other low-level API functions: drive_token, make_request, process_response
Examples
## Not run:
req <- generate_request(
"drive.files.get",
list(fileId = "abc"),
token = drive_token()
)
req
## End(Not run)
## re-create the previous request, but the hard way, i.e. "by hand"
req <- build_request(
path = "drive/v3/files/{fileId}",
method = "GET",
list(fileId = "abc", key = "an-api-key"),
token = NULL
)
req
googledrive 43
## End(Not run)
googledrive googledrive.
Description
googledrive.
Description
Low-level functions to execute one or more Drive API requests and, perhaps, process the re-
sponse(s). Most users should, instead, use higher-level wrappers that facilitate common tasks, such
as uploading or downloading Drive files. The functions here are intended for internal use and for
programming around the Drive API. Three functions are documented here:
• make_request() does the bare minimum: just calls an HTTP method, only adding the googledrive
user agent. Typically the input is created with generate_request() or build_request()
and the output is processed with process_response().
• do_request() is simply process_response(make_request(x, ...)). It exists only be-
cause we had to make do_paginated_request() and it felt weird to not make the equivalent
for a single request.
• do_paginated_request() executes the input request with page traversal. It is impossible
to separate paginated requests into a "make request" step and a "process request" step, because
the token for the next page must be extracted from the content of the current page. Therefore
this function does both and returns a list of processed responses, one per page.
44 make_request
Usage
make_request(x, ...)
do_request(x, ...)
Arguments
x List, holding the components for an HTTP request, presumably created with
generate_request() or build_request(). Should contain the method, path,
query, body, token, and url.
... Optional arguments passed through to the HTTP method.
n_max Maximum number of items to return. Defaults to Inf, i.e. there is no limit and
we keep making requests until we get all items.
n Function that computes the number of items in one response or page. The default
function always returns 1 and therefore treats each page as an item. If you know
more about the structure of the response, you can pass another function to count
and threshhold, for example, the number of files or comments.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
make_request(): Object of class response from httr.
do_request(): List representing the content returned by a single request.
do_paginated_request(): List of lists, representing the returned content, one component per
page.
See Also
Other low-level API functions: drive_token, generate_request, process_response
Examples
## Not run:
## build a request for an endpoint that is:
## * paginated
## * NOT privileged in googledrive, i.e. not covered by generate_request()
## "comments" are a great example
## https://developers.google.com/drive/v3/reference/comments
##
## Practice with a target file with > 2 comments
## Note that we request 2 items (comments) per page
req <- build_request(
path = "drive/v3/files/{fileId}/comments",
method = "GET",
params = list(
process_response 45
fileId = "your-file-id-goes-here",
fields = "*",
pageSize = 2
),
token = googledrive:::drive_token()
)
## make the paginated request, but cap it at 1 page
## should get back exactly two comments
do_paginated_request(req, n_max = 1)
## End(Not run)
Description
Process a response from the Google Drive v3 API
Usage
process_response(res)
Arguments
res Object of class response from httr.
Value
List.
See Also
Other low-level API functions: drive_token, generate_request, make_request
Description
How to capture a Team Drive or files/folders that live on a Team Drive for downstream use:
• drive_find() and drive_get() return a dribble with metadata on files, including folders.
Both can be directed to search on Team Drives, using the optional arguments team_drive or
corpus (documented below).
46 team_drives
Regard the functions above as the official "port of entry" for Team Drives and Team Drive files
and folders. Use them to capture your target(s) in a dribble to pass along to other googledrive
functions. The general flexibility to refer to files by name, path, or id does not apply to Team
Drive files. While it’s always a good idea to get things into a dribble early, for Team Drives it’s
absolutely required.
Note: Team Drives are only available to users of certain enhanced Google services, such as G Suite
Enterprise, G Suite Business, or G Suite for Education.
Other collections
To search other collections, pass the corpus parameter somewhere in the call, like so:
• "user": Queries files that the user has accessed, including both Team and non-Team Drive
files.
• "all": Queries files that the user has accessed and all Team Drives in which they are a mem-
ber. If you’re reading the Drive API docs, this is a googledrive convenience short cut for
"user,allTeamDrives".
• "domain": Queries files that are shared to the domain, including both Team Drive and non-
Team Drive files.
API docs
googledrive implements Team Drive support as outlined here:
• https://developers.google.com/drive/v3/web/enable-teamdrives#including_team_
drive_content_fileslist
team_drive_create 47
Users shouldn’t need to know any of this, but here are details for the curious. The extra information
needed to search Team Drives consists of the following query parameters:
Description
Usage
Arguments
name Character. Name of the new Team Drive. Must be non-empty and not entirely
whitespace.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
See Also
• https://developers.google.com/drive/v3/reference/teamdrives/create
48 team_drive_find
Examples
## Not run:
team_drive_create("my-awesome-team-drive")
## clean up
team_drive_rm("my-awesome-team-drive")
## End(Not run)
Description
This is the closest googledrive function to what you get from visiting https://drive.google.com
and clicking "Team Drives".
Note: Team Drives are only available to users of certain enhanced Google services, such as G Suite
Enterprise, G Suite Business, or G Suite for Education.
Usage
team_drive_find(pattern = NULL, n_max = Inf, ..., verbose = TRUE)
Arguments
pattern Character. If provided, only the items whose names match this regular expres-
sion are returned. This is implemented locally on the results returned by the
API.
n_max Integer. An upper bound on the number of items to return. This applies to the
results requested from the API, which may be further filtered locally, via the
pattern argument.
... Other parameters to pass along in the request, such as pageSize.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
See Also
Wraps the teamdrives.list endpoint::
• https://developers.google.com/drive/v3/reference/teamdrives/list
team_drive_get 49
Examples
## Not run:
team_drive_find()
## End(Not run)
Description
Retrieve metadata for Team Drives specified via name or id. Note that Google Drive does NOT
behave like your local file system:
• You can get zero, one, or more Team Drives back for each name! Team Drive names need not
be unique.
Note: Team Drives are only available to users of certain enhanced Google services, such as G Suite
Enterprise, G Suite Business, or G Suite for Education.
Usage
team_drive_get(name = NULL, id = NULL, verbose = TRUE)
Arguments
name Character vector of names. A character vector marked with as_id() is treated
as if it was provided via the id argument.
id Character vector of Team Drive ids or URLs (it is first processed with as_id()).
If both name and id are non-NULL, id is silently ignored.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
Examples
## Not run:
team_drive_get("my-awesome-team-drive")
team_drive_get(c("apple", "orange", "banana"))
team_drive_get(as_id("KCmiHLXUk9PVA-0AJNG"))
team_drive_get(as_id("https://drive.google.com/drive/u/0/folders/KCmiHLXUk9PVA-0AJNG"))
team_drive_get(id = "KCmiHLXUk9PVA-0AJNG")
team_drive_get(id = "https://drive.google.com/drive/u/0/folders/KCmiHLXUk9PVA-0AJNG")
## End(Not run)
50 team_drive_rm
Description
Delete Team Drives
Note: Team Drives are only available to users of certain enhanced Google services, such as G Suite
Enterprise, G Suite Business, or G Suite for Education.
Usage
team_drive_rm(team_drive = NULL, verbose = TRUE)
Arguments
team_drive Anything that identifies the Team Drive(s) of interest. Can be a character vector
of names, a character vector of file ids or URLs marked with as_id(), or a
dribble consisting only of Team Drives.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
Logical vector, indicating whether the delete succeeded.
See Also
Wraps the teamdrives.delete endpoint:
• https://developers.google.com/drive/v3/reference/teamdrives/delete
Examples
## Not run:
## Create Team Drives to remove in various ways
team_drive_create("testdrive-01")
td02 <- team_drive_create("testdrive-02")
team_drive_create("testdrive-03")
td04 <- team_drive_create("testdrive-04")
## remove by name
team_drive_rm("testdrive-01")
## remove by id
team_drive_rm(as_id(td02))
## remove by URL (or, rather, id found in URL)
team_drive_rm(as_id("https://drive.google.com/drive/u/0/folders/Q5DqUk9PVA"))
## remove by dribble
team_drive_rm(td04)
## End(Not run)
team_drive_update 51
Description
Update the metadata of an existing Team Drive, e.g. its background image or theme.
Note: Team Drives are only available to users of certain enhanced Google services, such as G Suite
Enterprise, G Suite Business, or G Suite for Education.
Usage
team_drive_update(team_drive, ..., verbose = TRUE)
Arguments
team_drive Anything that identifies one specific Team Drive: its name, its id or URL marked
with as_id(), or a dribble. Is pre-processed with as_team_drive(). Read
more about Team Drives.
... Named parameters to pass along to the Drive API. See the "Request body" sec-
tion of the Drive API docs for the associated endpoint.
verbose Logical, indicating whether to print informative messages (default TRUE).
Value
An object of class dribble, a tibble with one row per item.
See Also
Wraps the teamdrives.update endpoint:
• https://developers.google.com/drive/v3/reference/teamdrives/update
Examples
## Not run:
## create a Team Drive
td <- team_drive_create("I love themes!")
## clean up
team_drive_rm(td)
52 team_drive_update
## End(Not run)
Index
53
54 INDEX
httr::oauth_app(), 11
is_dribble (dribble-checks), 6
is_folder (dribble-checks), 6
is_mine (dribble-checks), 6
is_native (dribble-checks), 6
is_parental (dribble-checks), 6
is_team_drive (dribble-checks), 6
is_team_drivy (dribble-checks), 6
no_file (dribble-checks), 6
prep_fields (drive_fields), 18
process_response, 36, 42, 44, 45
process_response(), 43
single_file (dribble-checks), 6
some_files (dribble-checks), 6