Retrieves metadata for files specified via
path or via file
function is quite straightforward if you specify files by
id. But there are
some important considerations when you specify your target files by
See below for more. If the target files are specified via
dribble will include a
1 2 3 4 5 6 7 8
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!). If
Character vector of Drive file ids or URLs (it is first processed
Anything that identifies one specific shared drive: its
name, its id or URL marked with
Character, specifying which collections of items to search.
Relevant to those who work with shared drives and/or Google Workspace
domains. If specified, must be one of
This logical argument to
individual googledrive functions is deprecated. To globally suppress
googledrive messaging, use
An object of class
dribble, a tibble with one row per file.
If the target files were specified via
there will be a
Google Drive does NOT behave like your local file system! File and folder names need not be unique, even at a given level of the hierarchy. This means that a single path can describe multiple files (or 0 or exactly 1).
A single file can also be compatible with multiple paths, i.e. one path
could be more specific than the other. A file located at
be found as
~/alfa/bravo. If all 3 of those
were included in the input
path, they would be represented by a
single row in the output.
It's best to think of
drive_get() as a setwise operation when using file
paths. Do not assume that the
i-th input path corresponds to row
the output (although it often does!). If there's not a 1-to-1 relationship
between the input and output, this will be announced in a message.
drive_get() performs just enough path resolution to uniquely identify a
file compatible with each input
path, for all
paths at once. If you
absolutely want the full canonical path, run the output of
If you want to get a file via
path and it's not necessarily on your My
Drive, you may need to specify the
corpus arguments to
search other collections of items. Read more about shared drives.
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
# 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") # set up some files to get by path alfalfa <- drive_mkdir("alfalfa") broccoli <- drive_upload( drive_example_local("chicken.txt"), name = "broccoli", path = alfalfa ) drive_get("broccoli") drive_get("alfalfa/broccoli") drive_get("~/alfalfa/broccoli") drive_get(c("broccoli", "alfalfa/", "~/alfalfa/broccoli")) # clean up drive_rm(alfalfa) ## Not run: # The examples below are indicative of correct syntax. # But note these will generally result in an error or a # 0-row dribble, unless you replace the inputs with paths # or file ids that exist in your Drive. # multiple names drive_get(c("abc", "def")) # multiple names, one of which must be a folder drive_get(c("abc", "def/")) # query by file id(s) drive_get(id = "abcdefgeh123456789") drive_get(as_id("abcdefgeh123456789")) drive_get(id = c("abcdefgh123456789", "jklmnopq123456789")) # apply to a browser URL for, e.g., a Google Sheet my_url <- "https://docs.google.com/spreadsheets/d/FILE_ID/edit#gid=SHEET_ID" drive_get(my_url) drive_get(as_id(my_url)) drive_get(id = my_url) # access the shared drive named "foo" # shared_drive params must be specified if getting by path foo <- shared_drive_get("foo") drive_get(c("this.jpg", "that-file"), shared_drive = foo) # shared_drive params are not necessary if getting by id drive_get(as_id("123456789")) # search all shared drives and other files user has accessed drive_get(c("this.jpg", "that-file"), corpus = "allDrives") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.