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)

Value

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").

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:

Examples

# Get a few of your files
files <- drive_find(n_max = 10, trashed = NA)

# the "special" cases that require additional API calls and can be slow
drive_reveal(files, "path")
#> # A dribble: 10 × 4
#>    name                    path                      id           drive_resource
#>    <chr>                   <chr>                     <drv_id>     <list>        
#>  1 name-squatter           ~/name-squatter           1_PwAo5QYC9… <named list [
#>  2 name-squatter           ~/name-squatter           1DcwA7ipf17… <named list [
#>  3 name-squatter           ~/name-squatter           1uX4pCdu-8p… <named list [
#>  4 name-squatter           ~/name-squatter           1eMpgKGwxxF… <named list [
#>  5 name-squatter           ~/name-squatter           1jT4H3n8dDX… <named list [
#>  6 name-squatter           ~/name-squatter           134U1s5EDIa… <named list [
#>  7 name-squatter           ~/name-squatter           1SDRfYsJjCF… <named list [
#>  8 name-squatter           ~/name-squatter           1bQ4MkjT3Yv… <named list [
#>  9 2021-09-16_r_logo.jpg   ~/2021-09-16_r_logo.jpg   1dandXB0QZp… <named list [
#> 10 2021-09-16_r_about.html ~/2021-09-16_r_about.html 1XfCI_orH4o… <named list [
drive_reveal(files, "permissions")
#> # A dribble: 10 × 5
#>    name                    shared id            drive_resource permissions_reso…
#>    <chr>                   <lgl>  <drv_id>      <list>         <list>           
#>  1 name-squatter           FALSE  1_PwAo5QYC94… <named list [<named list [2]> 
#>  2 name-squatter           FALSE  1DcwA7ipf17p… <named list [<named list [2]> 
#>  3 name-squatter           FALSE  1uX4pCdu-8pl… <named list [<named list [2]> 
#>  4 name-squatter           FALSE  1eMpgKGwxxF9… <named list [<named list [2]> 
#>  5 name-squatter           FALSE  1jT4H3n8dDXc… <named list [<named list [2]> 
#>  6 name-squatter           FALSE  134U1s5EDIa_… <named list [<named list [2]> 
#>  7 name-squatter           FALSE  1SDRfYsJjCFM… <named list [<named list [2]> 
#>  8 name-squatter           FALSE  1bQ4MkjT3Yv0… <named list [<named list [2]> 
#>  9 2021-09-16_r_logo.jpg   FALSE  1dandXB0QZpj… <named list [<named list [2]> 
#> 10 2021-09-16_r_about.html FALSE  1XfCI_orH4oN… <named list [<named list [2]> 
drive_reveal(files, "published")
#> # A dribble: 10 × 5
#>    name                    published id          drive_resource revision_resour…
#>    <chr>                   <lgl>     <drv_id>    <list>         <list>          
#>  1 name-squatter           FALSE     1_PwAo5QYC… <named list [<named list [9]>
#>  2 name-squatter           FALSE     1DcwA7ipf1… <named list [<named list [9]>
#>  3 name-squatter           FALSE     1uX4pCdu-8… <named list [<named list [9]>
#>  4 name-squatter           FALSE     1eMpgKGwxx… <named list [<named list [9]>
#>  5 name-squatter           FALSE     1jT4H3n8dD… <named list [<named list [9]>
#>  6 name-squatter           FALSE     134U1s5EDI… <named list [<named list [9]>
#>  7 name-squatter           FALSE     1SDRfYsJjC… <named list [<named list [9]>
#>  8 name-squatter           FALSE     1bQ4MkjT3Y… <named list [<named list [9]>
#>  9 2021-09-16_r_logo.jpg   FALSE     1dandXB0QZ… <named list [<named list [10
#> 10 2021-09-16_r_about.html FALSE     1XfCI_orH4… <named list [<named list [10

# a "special" case of digging info out of `drive_resource`, then processing
# a bit
drive_reveal(files, "parent")
#> # A dribble: 10 × 4
#>    name                    id_parent           id                drive_resource 
#>    <chr>                   <drv_id>            <drv_id>          <list>         
#>  1 name-squatter           0AO_RMaBzcP63Uk9PVA 1_PwAo5QYC94jxMt… <named list [3
#>  2 name-squatter           0AO_RMaBzcP63Uk9PVA 1DcwA7ipf17p4WVk… <named list [3
#>  3 name-squatter           0AO_RMaBzcP63Uk9PVA 1uX4pCdu-8plKUuG… <named list [3
#>  4 name-squatter           0AO_RMaBzcP63Uk9PVA 1eMpgKGwxxF93qKf… <named list [3
#>  5 name-squatter           0AO_RMaBzcP63Uk9PVA 1jT4H3n8dDXc1-D3… <named list [3
#>  6 name-squatter           0AO_RMaBzcP63Uk9PVA 134U1s5EDIa_s7_b… <named list [3
#>  7 name-squatter           0AO_RMaBzcP63Uk9PVA 1SDRfYsJjCFMy0qc… <named list [3
#>  8 name-squatter           0AO_RMaBzcP63Uk9PVA 1bQ4MkjT3Yv0y-xh… <named list [3
#>  9 2021-09-16_r_logo.jpg   0AO_RMaBzcP63Uk9PVA 1dandXB0QZpjeGQq… <named list [4
#> 10 2021-09-16_r_about.html 0AO_RMaBzcP63Uk9PVA 1XfCI_orH4oNUZh0… <named list [4

# the "simple" cases of digging info out of `drive_resource`
drive_reveal(files, "trashed")
#> # A dribble: 10 × 4
#>    name                    trashed id                                drive_resource
#>    <chr>                   <lgl>   <drv_id>                          <list>        
#>  1 name-squatter           FALSE   1_PwAo5QYC94jxMtZKHaNIlZ-BpRSwwvc <named list [
#>  2 name-squatter           FALSE   1DcwA7ipf17p4WVktdtMjZNL22hzdn58c <named list [
#>  3 name-squatter           FALSE   1uX4pCdu-8plKUuGuqLaXdxHs1fllPs_O <named list [
#>  4 name-squatter           FALSE   1eMpgKGwxxF93qKfuwlY2LawKb8dy3_HH <named list [
#>  5 name-squatter           FALSE   1jT4H3n8dDXc1-D3mTaekGNwCHnVzlLJn <named list [
#>  6 name-squatter           FALSE   134U1s5EDIa_s7_b2m7y8OvzXT0n6I4tJ <named list [
#>  7 name-squatter           FALSE   1SDRfYsJjCFMy0qcKWMSdXNXcvkJlBqw4 <named list [
#>  8 name-squatter           FALSE   1bQ4MkjT3Yv0y-xhN3YFpqKf4BzV_WAvS <named list [
#>  9 2021-09-16_r_logo.jpg   FALSE   1dandXB0QZpjeGQq_56wTXKNwaqgsOa9D <named list [
#> 10 2021-09-16_r_about.html FALSE   1XfCI_orH4oNUZh06C4w6vXtno-BT_zmZ <named list [
drive_reveal(files, "mime_type")
#> # A dribble: 10 × 4
#>    name                    mime_type                id            drive_resource
#>    <chr>                   <chr>                    <drv_id>      <list>        
#>  1 name-squatter           application/octet-stream 1_PwAo5QYC94… <named list [
#>  2 name-squatter           application/octet-stream 1DcwA7ipf17p… <named list [
#>  3 name-squatter           application/octet-stream 1uX4pCdu-8pl… <named list [
#>  4 name-squatter           application/octet-stream 1eMpgKGwxxF9… <named list [
#>  5 name-squatter           application/octet-stream 1jT4H3n8dDXc… <named list [
#>  6 name-squatter           application/octet-stream 134U1s5EDIa_… <named list [
#>  7 name-squatter           application/octet-stream 1SDRfYsJjCFM… <named list [
#>  8 name-squatter           application/octet-stream 1bQ4MkjT3Yv0… <named list [
#>  9 2021-09-16_r_logo.jpg   image/jpeg               1dandXB0QZpj… <named list [
#> 10 2021-09-16_r_about.html text/html                1XfCI_orH4oN… <named list [
drive_reveal(files, "starred")
#> # A dribble: 10 × 4
#>    name                    starred id                                drive_resource
#>    <chr>                   <lgl>   <drv_id>                          <list>        
#>  1 name-squatter           FALSE   1_PwAo5QYC94jxMtZKHaNIlZ-BpRSwwvc <named list [
#>  2 name-squatter           FALSE   1DcwA7ipf17p4WVktdtMjZNL22hzdn58c <named list [
#>  3 name-squatter           FALSE   1uX4pCdu-8plKUuGuqLaXdxHs1fllPs_O <named list [
#>  4 name-squatter           FALSE   1eMpgKGwxxF93qKfuwlY2LawKb8dy3_HH <named list [
#>  5 name-squatter           FALSE   1jT4H3n8dDXc1-D3mTaekGNwCHnVzlLJn <named list [
#>  6 name-squatter           FALSE   134U1s5EDIa_s7_b2m7y8OvzXT0n6I4tJ <named list [
#>  7 name-squatter           FALSE   1SDRfYsJjCFMy0qcKWMSdXNXcvkJlBqw4 <named list [
#>  8 name-squatter           FALSE   1bQ4MkjT3Yv0y-xhN3YFpqKf4BzV_WAvS <named list [
#>  9 2021-09-16_r_logo.jpg   FALSE   1dandXB0QZpjeGQq_56wTXKNwaqgsOa9D <named list [
#> 10 2021-09-16_r_about.html FALSE   1XfCI_orH4oNUZh06C4w6vXtno-BT_zmZ <named list [
drive_reveal(files, "description")
#> # A dribble: 10 × 4
#>    name                    description id                                drive_resource
#>    <chr>                   <list>      <drv_id>                          <list>        
#>  1 name-squatter           <NULL>      1_PwAo5QYC94jxMtZKHaNIlZ-BpRSwwvc <named list [
#>  2 name-squatter           <NULL>      1DcwA7ipf17p4WVktdtMjZNL22hzdn58c <named list [
#>  3 name-squatter           <NULL>      1uX4pCdu-8plKUuGuqLaXdxHs1fllPs_O <named list [
#>  4 name-squatter           <NULL>      1eMpgKGwxxF93qKfuwlY2LawKb8dy3_HH <named list [
#>  5 name-squatter           <NULL>      1jT4H3n8dDXc1-D3mTaekGNwCHnVzlLJn <named list [
#>  6 name-squatter           <NULL>      134U1s5EDIa_s7_b2m7y8OvzXT0n6I4tJ <named list [
#>  7 name-squatter           <NULL>      1SDRfYsJjCFMy0qcKWMSdXNXcvkJlBqw4 <named list [
#>  8 name-squatter           <NULL>      1bQ4MkjT3Yv0y-xhN3YFpqKf4BzV_WAvS <named list [
#>  9 2021-09-16_r_logo.jpg   <NULL>      1dandXB0QZpjeGQq_56wTXKNwaqgsOa9D <named list [
#> 10 2021-09-16_r_about.html <NULL>      1XfCI_orH4oNUZh06C4w6vXtno-BT_zmZ <named list [
drive_reveal(files, "version")
#> # A dribble: 10 × 4
#>    name                    version id                                drive_resource
#>    <chr>                   <chr>   <drv_id>                          <list>        
#>  1 name-squatter           1       1_PwAo5QYC94jxMtZKHaNIlZ-BpRSwwvc <named list [
#>  2 name-squatter           1       1DcwA7ipf17p4WVktdtMjZNL22hzdn58c <named list [
#>  3 name-squatter           1       1uX4pCdu-8plKUuGuqLaXdxHs1fllPs_O <named list [
#>  4 name-squatter           1       1eMpgKGwxxF93qKfuwlY2LawKb8dy3_HH <named list [
#>  5 name-squatter           1       1jT4H3n8dDXc1-D3mTaekGNwCHnVzlLJn <named list [
#>  6 name-squatter           1       134U1s5EDIa_s7_b2m7y8OvzXT0n6I4tJ <named list [
#>  7 name-squatter           1       1SDRfYsJjCFMy0qcKWMSdXNXcvkJlBqw4 <named list [
#>  8 name-squatter           1       1bQ4MkjT3Yv0y-xhN3YFpqKf4BzV_WAvS <named list [
#>  9 2021-09-16_r_logo.jpg   3       1dandXB0QZpjeGQq_56wTXKNwaqgsOa9D <named list [
#> 10 2021-09-16_r_about.html 4       1XfCI_orH4oNUZh06C4w6vXtno-BT_zmZ <named list [
drive_reveal(files, "web_view_link")
#> # A dribble: 10 × 4
#>    name                    web_view_link              id          drive_resource
#>    <chr>                   <chr>                      <drv_id>    <list>        
#>  1 name-squatter           https://drive.google.com/… 1_PwAo5QYC… <named list [
#>  2 name-squatter           https://drive.google.com/… 1DcwA7ipf1… <named list [
#>  3 name-squatter           https://drive.google.com/… 1uX4pCdu-8… <named list [
#>  4 name-squatter           https://drive.google.com/… 1eMpgKGwxx… <named list [
#>  5 name-squatter           https://drive.google.com/… 1jT4H3n8dD… <named list [
#>  6 name-squatter           https://drive.google.com/… 134U1s5EDI… <named list [
#>  7 name-squatter           https://drive.google.com/… 1SDRfYsJjC… <named list [
#>  8 name-squatter           https://drive.google.com/… 1bQ4MkjT3Y… <named list [
#>  9 2021-09-16_r_logo.jpg   https://drive.google.com/… 1dandXB0QZ… <named list [
#> 10 2021-09-16_r_about.html https://drive.google.com/… 1XfCI_orH4… <named list [
drive_reveal(files, "modified_time")
#> # A dribble: 10 × 4
#>    name                    modified_time       id                drive_resource 
#>    <chr>                   <dttm>              <drv_id>          <list>         
#>  1 name-squatter           2021-09-24 13:43:58 1_PwAo5QYC94jxMt… <named list [3
#>  2 name-squatter           2021-09-23 13:46:57 1DcwA7ipf17p4WVk… <named list [3
#>  3 name-squatter           2021-09-22 13:44:10 1uX4pCdu-8plKUuG… <named list [3
#>  4 name-squatter           2021-09-21 13:43:11 1eMpgKGwxxF93qKf… <named list [3
#>  5 name-squatter           2021-09-20 13:44:08 1jT4H3n8dDXc1-D3… <named list [3
#>  6 name-squatter           2021-09-19 13:41:54 134U1s5EDIa_s7_b… <named list [3
#>  7 name-squatter           2021-09-18 13:41:44 1SDRfYsJjCFMy0qc… <named list [3
#>  8 name-squatter           2021-09-17 13:42:52 1bQ4MkjT3Yv0y-xh… <named list [3
#>  9 2021-09-16_r_logo.jpg   2021-09-16 13:45:57 1dandXB0QZpjeGQq… <named list [4
#> 10 2021-09-16_r_about.html 2021-09-16 13:45:56 1XfCI_orH4oNUZh0… <named list [4
drive_reveal(files, "created_time")
#> # A dribble: 10 × 4
#>    name                    created_time        id                drive_resource 
#>    <chr>                   <dttm>              <drv_id>          <list>         
#>  1 name-squatter           2021-09-24 13:43:58 1_PwAo5QYC94jxMt… <named list [3
#>  2 name-squatter           2021-09-23 13:46:57 1DcwA7ipf17p4WVk… <named list [3
#>  3 name-squatter           2021-09-22 13:44:10 1uX4pCdu-8plKUuG… <named list [3
#>  4 name-squatter           2021-09-21 13:43:11 1eMpgKGwxxF93qKf… <named list [3
#>  5 name-squatter           2021-09-20 13:44:08 1jT4H3n8dDXc1-D3… <named list [3
#>  6 name-squatter           2021-09-19 13:41:54 134U1s5EDIa_s7_b… <named list [3
#>  7 name-squatter           2021-09-18 13:41:44 1SDRfYsJjCFMy0qc… <named list [3
#>  8 name-squatter           2021-09-17 13:42:52 1bQ4MkjT3Yv0y-xh… <named list [3
#>  9 2021-09-16_r_logo.jpg   2021-09-16 13:45:51 1dandXB0QZpjeGQq… <named list [4
#> 10 2021-09-16_r_about.html 2021-09-16 13:45:50 1XfCI_orH4oNUZh0… <named list [4
drive_reveal(files, "owned_by_me")
#> # A dribble: 10 × 4
#>    name                    owned_by_me id                                drive_resource
#>    <chr>                   <lgl>       <drv_id>                          <list>        
#>  1 name-squatter           TRUE        1_PwAo5QYC94jxMtZKHaNIlZ-BpRSwwvc <named list [
#>  2 name-squatter           TRUE        1DcwA7ipf17p4WVktdtMjZNL22hzdn58c <named list [
#>  3 name-squatter           TRUE        1uX4pCdu-8plKUuGuqLaXdxHs1fllPs_O <named list [
#>  4 name-squatter           TRUE        1eMpgKGwxxF93qKfuwlY2LawKb8dy3_HH <named list [
#>  5 name-squatter           TRUE        1jT4H3n8dDXc1-D3mTaekGNwCHnVzlLJn <named list [
#>  6 name-squatter           TRUE        134U1s5EDIa_s7_b2m7y8OvzXT0n6I4tJ <named list [
#>  7 name-squatter           TRUE        1SDRfYsJjCFMy0qcKWMSdXNXcvkJlBqw4 <named list [
#>  8 name-squatter           TRUE        1bQ4MkjT3Yv0y-xhN3YFpqKf4BzV_WAvS <named list [
#>  9 2021-09-16_r_logo.jpg   TRUE        1dandXB0QZpjeGQq_56wTXKNwaqgsOa9D <named list [
#> 10 2021-09-16_r_about.html TRUE        1XfCI_orH4oNUZh06C4w6vXtno-BT_zmZ <named list [
drive_reveal(files, "size")
#> # A dribble: 10 × 4
#>    name                    size  id                                drive_resource
#>    <chr>                   <chr> <drv_id>                          <list>        
#>  1 name-squatter           0     1_PwAo5QYC94jxMtZKHaNIlZ-BpRSwwvc <named list [
#>  2 name-squatter           0     1DcwA7ipf17p4WVktdtMjZNL22hzdn58c <named list [
#>  3 name-squatter           0     1uX4pCdu-8plKUuGuqLaXdxHs1fllPs_O <named list [
#>  4 name-squatter           0     1eMpgKGwxxF93qKfuwlY2LawKb8dy3_HH <named list [
#>  5 name-squatter           0     1jT4H3n8dDXc1-D3mTaekGNwCHnVzlLJn <named list [
#>  6 name-squatter           0     134U1s5EDIa_s7_b2m7y8OvzXT0n6I4tJ <named list [
#>  7 name-squatter           0     1SDRfYsJjCFMy0qcKWMSdXNXcvkJlBqw4 <named list [
#>  8 name-squatter           0     1bQ4MkjT3Yv0y-xhN3YFpqKf4BzV_WAvS <named list [
#>  9 2021-09-16_r_logo.jpg   15985 1dandXB0QZpjeGQq_56wTXKNwaqgsOa9D <named list [
#> 10 2021-09-16_r_about.html 1972  1XfCI_orH4oNUZh06C4w6vXtno-BT_zmZ <named list [
drive_reveal(files, "quota_bytes_used")
#> # A dribble: 10 × 4
#>    name                    quota_bytes_used id                   drive_resource 
#>    <chr>                   <chr>            <drv_id>             <list>         
#>  1 name-squatter           0                1_PwAo5QYC94jxMtZKH… <named list [3
#>  2 name-squatter           0                1DcwA7ipf17p4WVktdt… <named list [3
#>  3 name-squatter           0                1uX4pCdu-8plKUuGuqL… <named list [3
#>  4 name-squatter           0                1eMpgKGwxxF93qKfuwl… <named list [3
#>  5 name-squatter           0                1jT4H3n8dDXc1-D3mTa… <named list [3
#>  6 name-squatter           0                134U1s5EDIa_s7_b2m7… <named list [3
#>  7 name-squatter           0                1SDRfYsJjCFMy0qcKWM… <named list [3
#>  8 name-squatter           0                1bQ4MkjT3Yv0y-xhN3Y… <named list [3
#>  9 2021-09-16_r_logo.jpg   15985            1dandXB0QZpjeGQq_56… <named list [4
#> 10 2021-09-16_r_about.html 1972             1XfCI_orH4oNUZh06C4… <named list [4

# 'root' is a special file id that represents your My Drive root folder
drive_get(id = "root") %>%
  drive_reveal("path")
#> # A dribble: 1 × 4
#>   name     path  id                  drive_resource   
#>   <chr>    <chr> <drv_id>            <list>           
#> 1 My Drive ~/    0AO_RMaBzcP63Uk9PVA <named list [31]>