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 whatappears 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-rename ~/name-squatter-rename 1eBgzhtUD3s0Av3v… <named list [3
#>  2 name-squatter-mv     ~/name-squatter-mv     1yvC2wblscLs-etp… <named list [3
#>  3 name-squatter-upload ~/name-squatter-upload 1PC1Jen5y-y_cK_R… <named list [3
#>  4 name-squatter-rename ~/name-squatter-rename 1qYqcqdMGZcDks3w… <named list [3
#>  5 name-squatter-mv     ~/name-squatter-mv     1luQgfQXegLgs8O5… <named list [3
#>  6 name-squatter-upload ~/name-squatter-upload 1ZMNpVlJ0TJFb-i_… <named list [3
#>  7 name-squatter-rename ~/name-squatter-rename 1abpL4BHrarnSlR4… <named list [3
#>  8 name-squatter-mv     ~/name-squatter-mv     1FdH4gwOpL7Rbk-L… <named list [3
#>  9 name-squatter-upload ~/name-squatter-upload 1R1tA0Ug_2l7P739… <named list [3
#> 10 name-squatter-rename ~/name-squatter-rename 1OYTz5plyH4RBD-D… <named list [3
drive_reveal(files, "permissions")
#> # A dribble: 10 × 5
#>    name                 shared id              drive_resource  permissions_reso…
#>    <chr>                <lgl>  <drv_id>        <list>          <list>           
#>  1 name-squatter-rename FALSE  1eBgzhtUD3s0Av… <named list [3<named list [2]> 
#>  2 name-squatter-mv     FALSE  1yvC2wblscLs-e… <named list [3<named list [2]> 
#>  3 name-squatter-upload FALSE  1PC1Jen5y-y_cK… <named list [3<named list [2]> 
#>  4 name-squatter-rename FALSE  1qYqcqdMGZcDks… <named list [3<named list [2]> 
#>  5 name-squatter-mv     FALSE  1luQgfQXegLgs8… <named list [3<named list [2]> 
#>  6 name-squatter-upload FALSE  1ZMNpVlJ0TJFb-… <named list [3<named list [2]> 
#>  7 name-squatter-rename FALSE  1abpL4BHrarnSl… <named list [3<named list [2]> 
#>  8 name-squatter-mv     FALSE  1FdH4gwOpL7Rbk… <named list [3<named list [2]> 
#>  9 name-squatter-upload FALSE  1R1tA0Ug_2l7P7… <named list [3<named list [2]> 
#> 10 name-squatter-rename FALSE  1OYTz5plyH4RBD… <named list [3<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-rename FALSE     1eBgzhtUD3s0… <named list [3<named list [9]>
#>  2 name-squatter-mv     FALSE     1yvC2wblscLs… <named list [3<named list [9]>
#>  3 name-squatter-upload FALSE     1PC1Jen5y-y_… <named list [3<named list [9]>
#>  4 name-squatter-rename FALSE     1qYqcqdMGZcD… <named list [3<named list [9]>
#>  5 name-squatter-mv     FALSE     1luQgfQXegLg… <named list [3<named list [9]>
#>  6 name-squatter-upload FALSE     1ZMNpVlJ0TJF… <named list [3<named list [9]>
#>  7 name-squatter-rename FALSE     1abpL4BHrarn… <named list [3<named list [9]>
#>  8 name-squatter-mv     FALSE     1FdH4gwOpL7R… <named list [3<named list [9]>
#>  9 name-squatter-upload FALSE     1R1tA0Ug_2l7… <named list [3<named list [9]>
#> 10 name-squatter-rename FALSE     1OYTz5plyH4R… <named list [3<named list [9]>

# 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-rename 0AO_RMaBzcP63Uk9PVA 1eBgzhtUD3s0Av3vmcv… <named list [3
#>  2 name-squatter-mv     0AO_RMaBzcP63Uk9PVA 1yvC2wblscLs-etpAMT… <named list [3
#>  3 name-squatter-upload 0AO_RMaBzcP63Uk9PVA 1PC1Jen5y-y_cK_RsTh… <named list [3
#>  4 name-squatter-rename 0AO_RMaBzcP63Uk9PVA 1qYqcqdMGZcDks3wtQy… <named list [3
#>  5 name-squatter-mv     0AO_RMaBzcP63Uk9PVA 1luQgfQXegLgs8O5NtC… <named list [3
#>  6 name-squatter-upload 0AO_RMaBzcP63Uk9PVA 1ZMNpVlJ0TJFb-i_Ioq… <named list [3
#>  7 name-squatter-rename 0AO_RMaBzcP63Uk9PVA 1abpL4BHrarnSlR4MjR… <named list [3
#>  8 name-squatter-mv     0AO_RMaBzcP63Uk9PVA 1FdH4gwOpL7Rbk-LVqO… <named list [3
#>  9 name-squatter-upload 0AO_RMaBzcP63Uk9PVA 1R1tA0Ug_2l7P739fCY… <named list [3
#> 10 name-squatter-rename 0AO_RMaBzcP63Uk9PVA 1OYTz5plyH4RBD-DRxf… <named list [3

# 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-rename TRUE    1eBgzhtUD3s0Av3vmcvHHvEPs130qtW8a <named list [
#>  2 name-squatter-mv     TRUE    1yvC2wblscLs-etpAMTwN-nRCITv_Rajv <named list [
#>  3 name-squatter-upload TRUE    1PC1Jen5y-y_cK_RsThW8ez52-m8ka6q7 <named list [
#>  4 name-squatter-rename TRUE    1qYqcqdMGZcDks3wtQyVSuY5030vYflpl <named list [
#>  5 name-squatter-mv     TRUE    1luQgfQXegLgs8O5NtCdA0aZiBxkrbQwg <named list [
#>  6 name-squatter-upload TRUE    1ZMNpVlJ0TJFb-i_IoqEeOzBUIc-S0n-D <named list [
#>  7 name-squatter-rename TRUE    1abpL4BHrarnSlR4MjRmgS3WeXlOV3HgZ <named list [
#>  8 name-squatter-mv     TRUE    1FdH4gwOpL7Rbk-LVqOTPOWLrFsQc2n_r <named list [
#>  9 name-squatter-upload TRUE    1R1tA0Ug_2l7P739fCYxdonEArP4tBKhJ <named list [
#> 10 name-squatter-rename TRUE    1OYTz5plyH4RBD-DRxfGL82o0olVQz6If <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-rename application/octet-stream 1eBgzhtUD3s0Av… <named list [3
#>  2 name-squatter-mv     application/octet-stream 1yvC2wblscLs-e… <named list [3
#>  3 name-squatter-upload application/octet-stream 1PC1Jen5y-y_cK… <named list [3
#>  4 name-squatter-rename application/octet-stream 1qYqcqdMGZcDks… <named list [3
#>  5 name-squatter-mv     application/octet-stream 1luQgfQXegLgs8… <named list [3
#>  6 name-squatter-upload application/octet-stream 1ZMNpVlJ0TJFb-… <named list [3
#>  7 name-squatter-rename application/octet-stream 1abpL4BHrarnSl… <named list [3
#>  8 name-squatter-mv     application/octet-stream 1FdH4gwOpL7Rbk… <named list [3
#>  9 name-squatter-upload application/octet-stream 1R1tA0Ug_2l7P7… <named list [3
#> 10 name-squatter-rename application/octet-stream 1OYTz5plyH4RBD… <named list [3
drive_reveal(files, "starred")
#> # A dribble: 10 × 4
#>    name                 starred id                                drive_resource
#>    <chr>                <lgl>   <drv_id>                          <list>        
#>  1 name-squatter-rename FALSE   1eBgzhtUD3s0Av3vmcvHHvEPs130qtW8a <named list [
#>  2 name-squatter-mv     FALSE   1yvC2wblscLs-etpAMTwN-nRCITv_Rajv <named list [
#>  3 name-squatter-upload FALSE   1PC1Jen5y-y_cK_RsThW8ez52-m8ka6q7 <named list [
#>  4 name-squatter-rename FALSE   1qYqcqdMGZcDks3wtQyVSuY5030vYflpl <named list [
#>  5 name-squatter-mv     FALSE   1luQgfQXegLgs8O5NtCdA0aZiBxkrbQwg <named list [
#>  6 name-squatter-upload FALSE   1ZMNpVlJ0TJFb-i_IoqEeOzBUIc-S0n-D <named list [
#>  7 name-squatter-rename FALSE   1abpL4BHrarnSlR4MjRmgS3WeXlOV3HgZ <named list [
#>  8 name-squatter-mv     FALSE   1FdH4gwOpL7Rbk-LVqOTPOWLrFsQc2n_r <named list [
#>  9 name-squatter-upload FALSE   1R1tA0Ug_2l7P739fCYxdonEArP4tBKhJ <named list [
#> 10 name-squatter-rename FALSE   1OYTz5plyH4RBD-DRxfGL82o0olVQz6If <named list [
drive_reveal(files, "description")
#> # A dribble: 10 × 4
#>    name                 description id                          drive_resource  
#>    <chr>                <list>      <drv_id>                    <list>          
#>  1 name-squatter-rename <NULL>      1eBgzhtUD3s0Av3vmcvHHvEPs1… <named list [39
#>  2 name-squatter-mv     <NULL>      1yvC2wblscLs-etpAMTwN-nRCI… <named list [39
#>  3 name-squatter-upload <NULL>      1PC1Jen5y-y_cK_RsThW8ez52-… <named list [39
#>  4 name-squatter-rename <NULL>      1qYqcqdMGZcDks3wtQyVSuY503… <named list [39
#>  5 name-squatter-mv     <NULL>      1luQgfQXegLgs8O5NtCdA0aZiB… <named list [39
#>  6 name-squatter-upload <NULL>      1ZMNpVlJ0TJFb-i_IoqEeOzBUI… <named list [39
#>  7 name-squatter-rename <NULL>      1abpL4BHrarnSlR4MjRmgS3WeX… <named list [39
#>  8 name-squatter-mv     <NULL>      1FdH4gwOpL7Rbk-LVqOTPOWLrF… <named list [39
#>  9 name-squatter-upload <NULL>      1R1tA0Ug_2l7P739fCYxdonEAr… <named list [39
#> 10 name-squatter-rename <NULL>      1OYTz5plyH4RBD-DRxfGL82o0o… <named list [39
drive_reveal(files, "version")
#> # A dribble: 10 × 4
#>    name                 version id                                drive_resource
#>    <chr>                <chr>   <drv_id>                          <list>        
#>  1 name-squatter-rename 2       1eBgzhtUD3s0Av3vmcvHHvEPs130qtW8a <named list [
#>  2 name-squatter-mv     2       1yvC2wblscLs-etpAMTwN-nRCITv_Rajv <named list [
#>  3 name-squatter-upload 2       1PC1Jen5y-y_cK_RsThW8ez52-m8ka6q7 <named list [
#>  4 name-squatter-rename 2       1qYqcqdMGZcDks3wtQyVSuY5030vYflpl <named list [
#>  5 name-squatter-mv     2       1luQgfQXegLgs8O5NtCdA0aZiBxkrbQwg <named list [
#>  6 name-squatter-upload 2       1ZMNpVlJ0TJFb-i_IoqEeOzBUIc-S0n-D <named list [
#>  7 name-squatter-rename 2       1abpL4BHrarnSlR4MjRmgS3WeXlOV3HgZ <named list [
#>  8 name-squatter-mv     2       1FdH4gwOpL7Rbk-LVqOTPOWLrFsQc2n_r <named list [
#>  9 name-squatter-upload 2       1R1tA0Ug_2l7P739fCYxdonEArP4tBKhJ <named list [
#> 10 name-squatter-rename 2       1OYTz5plyH4RBD-DRxfGL82o0olVQz6If <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-rename https://drive.google.com/fi… 1eBgzhtUD3s… <named list [
#>  2 name-squatter-mv     https://drive.google.com/fi… 1yvC2wblscL… <named list [
#>  3 name-squatter-upload https://drive.google.com/fi… 1PC1Jen5y-y… <named list [
#>  4 name-squatter-rename https://drive.google.com/fi… 1qYqcqdMGZc… <named list [
#>  5 name-squatter-mv     https://drive.google.com/fi… 1luQgfQXegL… <named list [
#>  6 name-squatter-upload https://drive.google.com/fi… 1ZMNpVlJ0TJ… <named list [
#>  7 name-squatter-rename https://drive.google.com/fi… 1abpL4BHrar… <named list [
#>  8 name-squatter-mv     https://drive.google.com/fi… 1FdH4gwOpL7… <named list [
#>  9 name-squatter-upload https://drive.google.com/fi… 1R1tA0Ug_2l… <named list [
#> 10 name-squatter-rename https://drive.google.com/fi… 1OYTz5plyH4… <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-rename 2022-01-19 13:41:41 1eBgzhtUD3s0Av3vmcv… <named list [3
#>  2 name-squatter-mv     2022-01-19 13:41:25 1yvC2wblscLs-etpAMT… <named list [3
#>  3 name-squatter-upload 2022-01-18 13:49:00 1PC1Jen5y-y_cK_RsTh… <named list [3
#>  4 name-squatter-rename 2022-01-18 13:48:26 1qYqcqdMGZcDks3wtQy… <named list [3
#>  5 name-squatter-mv     2022-01-18 13:48:10 1luQgfQXegLgs8O5NtC… <named list [3
#>  6 name-squatter-upload 2022-01-17 13:49:14 1ZMNpVlJ0TJFb-i_Ioq… <named list [3
#>  7 name-squatter-rename 2022-01-17 13:48:40 1abpL4BHrarnSlR4MjR… <named list [3
#>  8 name-squatter-mv     2022-01-17 13:48:24 1FdH4gwOpL7Rbk-LVqO… <named list [3
#>  9 name-squatter-upload 2022-01-16 13:47:48 1R1tA0Ug_2l7P739fCY… <named list [3
#> 10 name-squatter-rename 2022-01-16 13:47:15 1OYTz5plyH4RBD-DRxf… <named list [3
drive_reveal(files, "created_time")
#> # A dribble: 10 × 4
#>    name                 created_time        id                   drive_resource 
#>    <chr>                <dttm>              <drv_id>             <list>         
#>  1 name-squatter-rename 2022-01-19 13:41:41 1eBgzhtUD3s0Av3vmcv… <named list [3
#>  2 name-squatter-mv     2022-01-19 13:41:25 1yvC2wblscLs-etpAMT… <named list [3
#>  3 name-squatter-upload 2022-01-18 13:49:00 1PC1Jen5y-y_cK_RsTh… <named list [3
#>  4 name-squatter-rename 2022-01-18 13:48:26 1qYqcqdMGZcDks3wtQy… <named list [3
#>  5 name-squatter-mv     2022-01-18 13:48:10 1luQgfQXegLgs8O5NtC… <named list [3
#>  6 name-squatter-upload 2022-01-17 13:49:14 1ZMNpVlJ0TJFb-i_Ioq… <named list [3
#>  7 name-squatter-rename 2022-01-17 13:48:40 1abpL4BHrarnSlR4MjR… <named list [3
#>  8 name-squatter-mv     2022-01-17 13:48:24 1FdH4gwOpL7Rbk-LVqO… <named list [3
#>  9 name-squatter-upload 2022-01-16 13:47:48 1R1tA0Ug_2l7P739fCY… <named list [3
#> 10 name-squatter-rename 2022-01-16 13:47:15 1OYTz5plyH4RBD-DRxf… <named list [3
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-rename TRUE        1eBgzhtUD3s0Av3vmcvHHvEPs1… <named list [39
#>  2 name-squatter-mv     TRUE        1yvC2wblscLs-etpAMTwN-nRCI… <named list [39
#>  3 name-squatter-upload TRUE        1PC1Jen5y-y_cK_RsThW8ez52-… <named list [39
#>  4 name-squatter-rename TRUE        1qYqcqdMGZcDks3wtQyVSuY503… <named list [39
#>  5 name-squatter-mv     TRUE        1luQgfQXegLgs8O5NtCdA0aZiB… <named list [39
#>  6 name-squatter-upload TRUE        1ZMNpVlJ0TJFb-i_IoqEeOzBUI… <named list [39
#>  7 name-squatter-rename TRUE        1abpL4BHrarnSlR4MjRmgS3WeX… <named list [39
#>  8 name-squatter-mv     TRUE        1FdH4gwOpL7Rbk-LVqOTPOWLrF… <named list [39
#>  9 name-squatter-upload TRUE        1R1tA0Ug_2l7P739fCYxdonEAr… <named list [39
#> 10 name-squatter-rename TRUE        1OYTz5plyH4RBD-DRxfGL82o0o… <named list [39
drive_reveal(files, "size")
#> # A dribble: 10 × 4
#>    name                 size  id                                drive_resource  
#>    <chr>                <chr> <drv_id>                          <list>          
#>  1 name-squatter-rename 0     1eBgzhtUD3s0Av3vmcvHHvEPs130qtW8a <named list [39
#>  2 name-squatter-mv     0     1yvC2wblscLs-etpAMTwN-nRCITv_Rajv <named list [39
#>  3 name-squatter-upload 0     1PC1Jen5y-y_cK_RsThW8ez52-m8ka6q7 <named list [39
#>  4 name-squatter-rename 0     1qYqcqdMGZcDks3wtQyVSuY5030vYflpl <named list [39
#>  5 name-squatter-mv     0     1luQgfQXegLgs8O5NtCdA0aZiBxkrbQwg <named list [39
#>  6 name-squatter-upload 0     1ZMNpVlJ0TJFb-i_IoqEeOzBUIc-S0n-D <named list [39
#>  7 name-squatter-rename 0     1abpL4BHrarnSlR4MjRmgS3WeXlOV3HgZ <named list [39
#>  8 name-squatter-mv     0     1FdH4gwOpL7Rbk-LVqOTPOWLrFsQc2n_r <named list [39
#>  9 name-squatter-upload 0     1R1tA0Ug_2l7P739fCYxdonEArP4tBKhJ <named list [39
#> 10 name-squatter-rename 0     1OYTz5plyH4RBD-DRxfGL82o0olVQz6If <named list [39
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-rename 0                1eBgzhtUD3s0Av3vmcvHHv… <named list [3
#>  2 name-squatter-mv     0                1yvC2wblscLs-etpAMTwN-… <named list [3
#>  3 name-squatter-upload 0                1PC1Jen5y-y_cK_RsThW8e… <named list [3
#>  4 name-squatter-rename 0                1qYqcqdMGZcDks3wtQyVSu… <named list [3
#>  5 name-squatter-mv     0                1luQgfQXegLgs8O5NtCdA0… <named list [3
#>  6 name-squatter-upload 0                1ZMNpVlJ0TJFb-i_IoqEeO… <named list [3
#>  7 name-squatter-rename 0                1abpL4BHrarnSlR4MjRmgS… <named list [3
#>  8 name-squatter-mv     0                1FdH4gwOpL7Rbk-LVqOTPO… <named list [3
#>  9 name-squatter-upload 0                1R1tA0Ug_2l7P739fCYxdo… <named list [3
#> 10 name-squatter-rename 0                1OYTz5plyH4RBD-DRxfGL8… <named list [3

# '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]>