drive_reveal() adds extra information about your Drive files that is not readily available in the default dribble produced by googledrive. Why is this info not always included in the default dribble?
You don't always care about it. There is a lot of esoteric information in the drive_resource that has little value for most users.
It might be "expensive" to get this information and put it into a usable form. For example, revealing a file's "path", "permissions", or "published" status all require additional API calls.
drive_reveal() can also hoist any property out of the drive_resource
list-column, when the property's name is passed as the what argument. The resulting new column is simplified if it is easy to do so, e.g., if the individual elements are all string or logical. If what extracts a date-time, we return POSIXct. Otherwise, you'll get a list-column. If this makes you sad, consider using tidyr::hoist() instead. It is more powerful due to a richer "plucking specification" and its ptype
and transform arguments. Another useful function is tidyr::unnest_wider().
drive_reveal(file, what = c("path","permissions","published","parent"))
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. These values get special handling (more details below):
path
permissions
published
parent
You can also request any property in the drive_resource column by name. The request can be in camelCase or snake_case, but the new column name will always be snake_case. Some examples of what:
mime_type (or mimeType)
trashed
starred
description
version
web_view_link (or webViewLink)
modified_time (or modifiedTime)
created_time (or createdTime)
owned_by_me (or ownedByMe)
size
quota_bytes_used (or quotaBytesUsed)
Returns
An object of class dribble, a tibble with one row per file. The additional info requested via what
appears in one (or more) extra columns.
File path
When what = "path" the dribble gains a character column holding each file's path. This can be very slow, so use with caution.
The example path ~/a/b/ illustrates two conventions used in googledrive:
The leading ~/ means that the folder a is located in the current user's "My Drive" root folder.
The trailing / means that b, located in a, is a folder or a folder shortcut.
Permissions
When what = "permissions" the dribble gains a logical column shared
that indicates whether a file is shared and a new list-column permissions_resource containing lists of Permissions resources.
Publishing
When what = "published" the dribble gains a logical column published that indicates whether a file is published and a new list-column revision_resource containing lists of Revisions resources.
Parent
When what = "parent" the dribble gains a character column id_parent
that is the file id of this item's parent folder. This information is available in the drive_resource, but can't just be hoisted out:
Google Drive used to allow files to have multiple parents, but this is no longer supported and googledrive now assumes this is impossible. However, we have seen (very old) files that still have >1 parent folder. If we see this we message about it and drop all but the first parent.
The parents property in drive_resource has an "extra" layer of nesting and needs to be flattened.
If you really want the raw parents property, call drive_reveal(what = "parents").
Examples
# Get a few of your filesfiles <- drive_find(n_max =10, trashed =NA)# the "special" cases that require additional API calls and can be slowdrive_reveal(files,"path")drive_reveal(files,"permissions")drive_reveal(files,"published")# a "special" case of digging info out of `drive_resource`, then processing# a bitdrive_reveal(files,"parent")# the "simple" cases of digging info out of `drive_resource`drive_reveal(files,"trashed")drive_reveal(files,"mime_type")drive_reveal(files,"starred")drive_reveal(files,"description")drive_reveal(files,"version")drive_reveal(files,"web_view_link")drive_reveal(files,"modified_time")drive_reveal(files,"created_time")drive_reveal(files,"owned_by_me")drive_reveal(files,"size")drive_reveal(files,"quota_bytes_used")# 'root' is a special file id that represents your My Drive root folderdrive_get(id ="root")%>% drive_reveal("path")
See Also
To learn more about the properties present in the metadata of a Drive file (which is what's in the drive_resource list-column of a dribble), see the API docs: