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

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

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 item.

Special considerations for paths

Note that 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. 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.

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.

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.

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 x 4
#>    name          path            id                              drive_resource 
#>    <chr>         <chr>           <chr>                           <list>         
#>  1 name-squatter ~/name-squatter 19DFjQpTU14dpgD-90g1UnjoBDUr7R… <named list [3
#>  2 name-squatter name-squatter/  1ucrFopRYrgPcptuh_tvAZ5jBi0h8W… <named list [3
#>  3 name-squatter name-squatter   1HRRDhdIVVy9QrjVQqAIyghKF0eN6Z… <named list [3
#>  4 pqr           pqr/            1Vv1jOhWL8CXFCZtolfFN9kbF1f0JK… <named list [3
#>  5 mno           mno/            1RT483SrAsDZ21L0LWChkeBLCmxb0n… <named list [3
#>  6 jkl           jkl/            1koG9X_nvhct21LK6dpPVGZXwIOEpG… <named list [3
#>  7 chicken-cp.t… ~/chicken-cp.t… 12aURCBowkKSyQParyLCSgcHi0B68m… <named list [3
#>  8 drive-quiet-… ~/drive-quiet-… 1k21Fbb89dGcFzVlItCdXCzxVOzRrM… <named list [3
#>  9 name-squatter ~/name-squatter 147oSYRr-hMhijkZNn8EJR4chRzL4e… <named list [3
#> 10 name-squatter ~/name-squatter 1VFIICzv2WxSzXSgbJJXlGEJXMw7mX… <named list [3
drive_reveal(files, "permissions")
#> # A dribble: 10 x 5
#>    name        shared id                       drive_resource  permissions_reso…
#>  * <chr>       <lgl>  <chr>                    <list>          <list>           
#>  1 name-squat… FALSE  19DFjQpTU14dpgD-90g1Unj… <named list [3<named list [2]> 
#>  2 name-squat… FALSE  1ucrFopRYrgPcptuh_tvAZ5… <named list [3<named list [2]> 
#>  3 name-squat… FALSE  1HRRDhdIVVy9QrjVQqAIygh… <named list [3<named list [2]> 
#>  4 pqr         FALSE  1Vv1jOhWL8CXFCZtolfFN9k… <named list [3<named list [2]> 
#>  5 mno         FALSE  1RT483SrAsDZ21L0LWChkeB… <named list [3<named list [2]> 
#>  6 jkl         FALSE  1koG9X_nvhct21LK6dpPVGZ… <named list [3<named list [2]> 
#>  7 chicken-cp… FALSE  12aURCBowkKSyQParyLCSgc… <named list [3<named list [2]> 
#>  8 drive-quie… FALSE  1k21Fbb89dGcFzVlItCdXCz… <named list [3<named list [2]> 
#>  9 name-squat… FALSE  147oSYRr-hMhijkZNn8EJR4… <named list [3<named list [2]> 
#> 10 name-squat… FALSE  1VFIICzv2WxSzXSgbJJXlGE… <named list [3<named list [2]> 
drive_reveal(files, "published")
#> # A dribble: 10 x 5
#>    name        published id                     drive_resource  revision_resour…
#>  * <chr>       <lgl>     <chr>                  <list>          <list>          
#>  1 name-squat… FALSE     19DFjQpTU14dpgD-90g1U… <named list [3<named list [9]>
#>  2 name-squat… FALSE     1ucrFopRYrgPcptuh_tvA… <named list [3<NULL>          
#>  3 name-squat… FALSE     1HRRDhdIVVy9QrjVQqAIy… <named list [3<named list [9]>
#>  4 pqr         FALSE     1Vv1jOhWL8CXFCZtolfFN… <named list [3<NULL>          
#>  5 mno         FALSE     1RT483SrAsDZ21L0LWChk… <named list [3<NULL>          
#>  6 jkl         FALSE     1koG9X_nvhct21LK6dpPV… <named list [3<NULL>          
#>  7 chicken-cp… FALSE     12aURCBowkKSyQParyLCS… <named list [3<named list [10
#>  8 drive-quie… FALSE     1k21Fbb89dGcFzVlItCdX… <named list [3<named list [7]>
#>  9 name-squat… FALSE     147oSYRr-hMhijkZNn8EJ… <named list [3<named list [9]>
#> 10 name-squat… FALSE     1VFIICzv2WxSzXSgbJJXl… <named list [3<named list [9]>

# the "simple" cases of digging info out of `drive_resource`
drive_reveal(files, "trashed")
#> # A dribble: 10 x 4
#>    name            trashed id                                   drive_resource  
#>  * <chr>           <lgl>   <chr>                                <list>          
#>  1 name-squatter   TRUE    19DFjQpTU14dpgD-90g1UnjoBDUr7RJoZ    <named list [38
#>  2 name-squatter   FALSE   1ucrFopRYrgPcptuh_tvAZ5jBi0h8WGG6    <named list [32
#>  3 name-squatter   TRUE    1HRRDhdIVVy9QrjVQqAIyghKF0eN6ZALt    <named list [38
#>  4 pqr             FALSE   1Vv1jOhWL8CXFCZtolfFN9kbF1f0JK1o1    <named list [33
#>  5 mno             FALSE   1RT483SrAsDZ21L0LWChkeBLCmxb0ne37    <named list [32
#>  6 jkl             FALSE   1koG9X_nvhct21LK6dpPVGZXwIOEpGTSU    <named list [32
#>  7 chicken-cp.txt  TRUE    12aURCBowkKSyQParyLCSgcHi0B68mLDX    <named list [39
#>  8 drive-quiet-wo… TRUE    1k21Fbb89dGcFzVlItCdXCzxVOzRrM1Doc_… <named list [34
#>  9 name-squatter   TRUE    147oSYRr-hMhijkZNn8EJR4chRzL4eGGc    <named list [38
#> 10 name-squatter   TRUE    1VFIICzv2WxSzXSgbJJXlGEJXMw7mXyJd    <named list [38
drive_reveal(files, "mime_type")
#> # A dribble: 10 x 4
#>    name         mime_type               id                       drive_resource 
#>  * <chr>        <chr>                   <chr>                    <list>         
#>  1 name-squatt… application/octet-stre… 19DFjQpTU14dpgD-90g1Unj… <named list [3
#>  2 name-squatt… application/vnd.google… 1ucrFopRYrgPcptuh_tvAZ5… <named list [3
#>  3 name-squatt… application/octet-stre… 1HRRDhdIVVy9QrjVQqAIygh… <named list [3
#>  4 pqr          application/vnd.google… 1Vv1jOhWL8CXFCZtolfFN9k… <named list [3
#>  5 mno          application/vnd.google… 1RT483SrAsDZ21L0LWChkeB… <named list [3
#>  6 jkl          application/vnd.google… 1koG9X_nvhct21LK6dpPVGZ… <named list [3
#>  7 chicken-cp.… text/plain              12aURCBowkKSyQParyLCSgc… <named list [3
#>  8 drive-quiet… application/vnd.google… 1k21Fbb89dGcFzVlItCdXCz… <named list [3
#>  9 name-squatt… application/octet-stre… 147oSYRr-hMhijkZNn8EJR4… <named list [3
#> 10 name-squatt… application/octet-stre… 1VFIICzv2WxSzXSgbJJXlGE… <named list [3
drive_reveal(files, "starred")
#> # A dribble: 10 x 4
#>    name            starred id                                   drive_resource  
#>  * <chr>           <lgl>   <chr>                                <list>          
#>  1 name-squatter   FALSE   19DFjQpTU14dpgD-90g1UnjoBDUr7RJoZ    <named list [38
#>  2 name-squatter   FALSE   1ucrFopRYrgPcptuh_tvAZ5jBi0h8WGG6    <named list [32
#>  3 name-squatter   FALSE   1HRRDhdIVVy9QrjVQqAIyghKF0eN6ZALt    <named list [38
#>  4 pqr             FALSE   1Vv1jOhWL8CXFCZtolfFN9kbF1f0JK1o1    <named list [33
#>  5 mno             FALSE   1RT483SrAsDZ21L0LWChkeBLCmxb0ne37    <named list [32
#>  6 jkl             TRUE    1koG9X_nvhct21LK6dpPVGZXwIOEpGTSU    <named list [32
#>  7 chicken-cp.txt  FALSE   12aURCBowkKSyQParyLCSgcHi0B68mLDX    <named list [39
#>  8 drive-quiet-wo… FALSE   1k21Fbb89dGcFzVlItCdXCzxVOzRrM1Doc_… <named list [34
#>  9 name-squatter   FALSE   147oSYRr-hMhijkZNn8EJR4chRzL4eGGc    <named list [38
#> 10 name-squatter   FALSE   1VFIICzv2WxSzXSgbJJXlGEJXMw7mXyJd    <named list [38
drive_reveal(files, "description")
#> # A dribble: 10 x 4
#>    name           description  id                               drive_resource  
#>  * <chr>          <chr>        <chr>                            <list>          
#>  1 name-squatter  NA           19DFjQpTU14dpgD-90g1UnjoBDUr7RJ… <named list [38
#>  2 name-squatter  NA           1ucrFopRYrgPcptuh_tvAZ5jBi0h8WG… <named list [32
#>  3 name-squatter  NA           1HRRDhdIVVy9QrjVQqAIyghKF0eN6ZA… <named list [38
#>  4 pqr            I am a fold… 1Vv1jOhWL8CXFCZtolfFN9kbF1f0JK1… <named list [33
#>  5 mno            NA           1RT483SrAsDZ21L0LWChkeBLCmxb0ne… <named list [32
#>  6 jkl            NA           1koG9X_nvhct21LK6dpPVGZXwIOEpGT… <named list [32
#>  7 chicken-cp.txt NA           12aURCBowkKSyQParyLCSgcHi0B68mL… <named list [39
#>  8 drive-quiet-w… NA           1k21Fbb89dGcFzVlItCdXCzxVOzRrM1… <named list [34
#>  9 name-squatter  NA           147oSYRr-hMhijkZNn8EJR4chRzL4eG… <named list [38
#> 10 name-squatter  NA           1VFIICzv2WxSzXSgbJJXlGEJXMw7mXy… <named list [38
drive_reveal(files, "version")
#> # A dribble: 10 x 4
#>    name            version id                                   drive_resource  
#>  * <chr>           <chr>   <chr>                                <list>          
#>  1 name-squatter   2       19DFjQpTU14dpgD-90g1UnjoBDUr7RJoZ    <named list [38
#>  2 name-squatter   1       1ucrFopRYrgPcptuh_tvAZ5jBi0h8WGG6    <named list [32
#>  3 name-squatter   2       1HRRDhdIVVy9QrjVQqAIyghKF0eN6ZALt    <named list [38
#>  4 pqr             1       1Vv1jOhWL8CXFCZtolfFN9kbF1f0JK1o1    <named list [33
#>  5 mno             1       1RT483SrAsDZ21L0LWChkeBLCmxb0ne37    <named list [32
#>  6 jkl             1       1koG9X_nvhct21LK6dpPVGZXwIOEpGTSU    <named list [32
#>  7 chicken-cp.txt  3       12aURCBowkKSyQParyLCSgcHi0B68mLDX    <named list [39
#>  8 drive-quiet-wo… 10      1k21Fbb89dGcFzVlItCdXCzxVOzRrM1Doc_… <named list [34
#>  9 name-squatter   2       147oSYRr-hMhijkZNn8EJR4chRzL4eGGc    <named list [38
#> 10 name-squatter   2       1VFIICzv2WxSzXSgbJJXlGEJXMw7mXyJd    <named list [38
drive_reveal(files, "web_view_link")
#> # A dribble: 10 x 4
#>    name      web_view_link                      id                drive_resource
#>  * <chr>     <chr>                              <chr>             <list>        
#>  1 name-squ… https://drive.google.com/file/d/1… 19DFjQpTU14dpgD-… <named list [
#>  2 name-squ… https://drive.google.com/drive/fo… 1ucrFopRYrgPcptu… <named list [
#>  3 name-squ… https://drive.google.com/file/d/1… 1HRRDhdIVVy9QrjV… <named list [
#>  4 pqr       https://drive.google.com/drive/fo… 1Vv1jOhWL8CXFCZt… <named list [
#>  5 mno       https://drive.google.com/drive/fo… 1RT483SrAsDZ21L0… <named list [
#>  6 jkl       https://drive.google.com/drive/fo… 1koG9X_nvhct21LK… <named list [
#>  7 chicken-… https://drive.google.com/file/d/1… 12aURCBowkKSyQPa… <named list [
#>  8 drive-qu… https://docs.google.com/document/… 1k21Fbb89dGcFzVl… <named list [
#>  9 name-squ… https://drive.google.com/file/d/1… 147oSYRr-hMhijkZ… <named list [
#> 10 name-squ… https://drive.google.com/file/d/1… 1VFIICzv2WxSzXSg… <named list [
drive_reveal(files, "modified_time")
#> # A dribble: 10 x 4
#>    name         modified_time       id                           drive_resource 
#>    <chr>        <dttm>              <chr>                        <list>         
#>  1 name-squatt… 2021-05-15 13:52:26 19DFjQpTU14dpgD-90g1UnjoBDU… <named list [3
#>  2 name-squatt… 2021-05-15 13:52:18 1ucrFopRYrgPcptuh_tvAZ5jBi0… <named list [3
#>  3 name-squatt… 2021-05-15 13:52:16 1HRRDhdIVVy9QrjVQqAIyghKF0e… <named list [3
#>  4 pqr          2021-05-15 13:52:16 1Vv1jOhWL8CXFCZtolfFN9kbF1f… <named list [3
#>  5 mno          2021-05-15 13:52:15 1RT483SrAsDZ21L0LWChkeBLCmx… <named list [3
#>  6 jkl          2021-05-15 13:52:15 1koG9X_nvhct21LK6dpPVGZXwIO… <named list [3
#>  7 chicken-cp.… 2021-05-15 13:51:34 12aURCBowkKSyQParyLCSgcHi0B… <named list [3
#>  8 drive-quiet… 2021-05-14 13:54:15 1k21Fbb89dGcFzVlItCdXCzxVOz… <named list [3
#>  9 name-squatt… 2021-05-14 13:54:08 147oSYRr-hMhijkZNn8EJR4chRz… <named list [3
#> 10 name-squatt… 2021-05-14 13:53:30 1VFIICzv2WxSzXSgbJJXlGEJXMw… <named list [3
drive_reveal(files, "created_time")
#> # A dribble: 10 x 4
#>    name         created_time        id                           drive_resource 
#>    <chr>        <dttm>              <chr>                        <list>         
#>  1 name-squatt… 2021-05-15 13:52:26 19DFjQpTU14dpgD-90g1UnjoBDU… <named list [3
#>  2 name-squatt… 2021-05-15 13:52:18 1ucrFopRYrgPcptuh_tvAZ5jBi0… <named list [3
#>  3 name-squatt… 2021-05-15 13:52:16 1HRRDhdIVVy9QrjVQqAIyghKF0e… <named list [3
#>  4 pqr          2021-05-15 13:52:16 1Vv1jOhWL8CXFCZtolfFN9kbF1f… <named list [3
#>  5 mno          2021-05-15 13:52:15 1RT483SrAsDZ21L0LWChkeBLCmx… <named list [3
#>  6 jkl          2021-05-15 13:52:15 1koG9X_nvhct21LK6dpPVGZXwIO… <named list [3
#>  7 chicken-cp.… 2021-05-15 13:51:34 12aURCBowkKSyQParyLCSgcHi0B… <named list [3
#>  8 drive-quiet… 2021-05-14 13:54:13 1k21Fbb89dGcFzVlItCdXCzxVOz… <named list [3
#>  9 name-squatt… 2021-05-14 13:54:08 147oSYRr-hMhijkZNn8EJR4chRz… <named list [3
#> 10 name-squatt… 2021-05-14 13:53:30 1VFIICzv2WxSzXSgbJJXlGEJXMw… <named list [3
drive_reveal(files, "owned_by_me")
#> # A dribble: 10 x 4
#>    name           owned_by_me id                                drive_resource  
#>  * <chr>          <lgl>       <chr>                             <list>          
#>  1 name-squatter  TRUE        19DFjQpTU14dpgD-90g1UnjoBDUr7RJoZ <named list [38
#>  2 name-squatter  TRUE        1ucrFopRYrgPcptuh_tvAZ5jBi0h8WGG6 <named list [32
#>  3 name-squatter  TRUE        1HRRDhdIVVy9QrjVQqAIyghKF0eN6ZALt <named list [38
#>  4 pqr            TRUE        1Vv1jOhWL8CXFCZtolfFN9kbF1f0JK1o1 <named list [33
#>  5 mno            TRUE        1RT483SrAsDZ21L0LWChkeBLCmxb0ne37 <named list [32
#>  6 jkl            TRUE        1koG9X_nvhct21LK6dpPVGZXwIOEpGTSU <named list [32
#>  7 chicken-cp.txt TRUE        12aURCBowkKSyQParyLCSgcHi0B68mLDX <named list [39
#>  8 drive-quiet-w… TRUE        1k21Fbb89dGcFzVlItCdXCzxVOzRrM1D… <named list [34
#>  9 name-squatter  TRUE        147oSYRr-hMhijkZNn8EJR4chRzL4eGGc <named list [38
#> 10 name-squatter  TRUE        1VFIICzv2WxSzXSgbJJXlGEJXMw7mXyJd <named list [38
drive_reveal(files, "size")
#> # A dribble: 10 x 4
#>    name            size  id                                     drive_resource  
#>  * <chr>           <chr> <chr>                                  <list>          
#>  1 name-squatter   0     19DFjQpTU14dpgD-90g1UnjoBDUr7RJoZ      <named list [38
#>  2 name-squatter   NA    1ucrFopRYrgPcptuh_tvAZ5jBi0h8WGG6      <named list [32
#>  3 name-squatter   0     1HRRDhdIVVy9QrjVQqAIyghKF0eN6ZALt      <named list [38
#>  4 pqr             NA    1Vv1jOhWL8CXFCZtolfFN9kbF1f0JK1o1      <named list [33
#>  5 mno             NA    1RT483SrAsDZ21L0LWChkeBLCmxb0ne37      <named list [32
#>  6 jkl             NA    1koG9X_nvhct21LK6dpPVGZXwIOEpGTSU      <named list [32
#>  7 chicken-cp.txt  165   12aURCBowkKSyQParyLCSgcHi0B68mLDX      <named list [39
#>  8 drive-quiet-wo… NA    1k21Fbb89dGcFzVlItCdXCzxVOzRrM1Doc_pP… <named list [34
#>  9 name-squatter   0     147oSYRr-hMhijkZNn8EJR4chRzL4eGGc      <named list [38
#> 10 name-squatter   0     1VFIICzv2WxSzXSgbJJXlGEJXMw7mXyJd      <named list [38
drive_reveal(files, "quota_bytes_used")
#> # A dribble: 10 x 4
#>    name          quota_bytes_used id                             drive_resource 
#>  * <chr>         <chr>            <chr>                          <list>         
#>  1 name-squatter 0                19DFjQpTU14dpgD-90g1UnjoBDUr7… <named list [3
#>  2 name-squatter 0                1ucrFopRYrgPcptuh_tvAZ5jBi0h8… <named list [3
#>  3 name-squatter 0                1HRRDhdIVVy9QrjVQqAIyghKF0eN6… <named list [3
#>  4 pqr           0                1Vv1jOhWL8CXFCZtolfFN9kbF1f0J… <named list [3
#>  5 mno           0                1RT483SrAsDZ21L0LWChkeBLCmxb0… <named list [3
#>  6 jkl           0                1koG9X_nvhct21LK6dpPVGZXwIOEp… <named list [3
#>  7 chicken-cp.t… 165              12aURCBowkKSyQParyLCSgcHi0B68… <named list [3
#>  8 drive-quiet-… 0                1k21Fbb89dGcFzVlItCdXCzxVOzRr… <named list [3
#>  9 name-squatter 0                147oSYRr-hMhijkZNn8EJR4chRzL4… <named list [3
#> 10 name-squatter 0                1VFIICzv2WxSzXSgbJJXlGEJXMw7m… <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 x 4
#>   name     path  id                  drive_resource   
#>   <chr>    <chr> <chr>               <list>           
#> 1 My Drive ~/    0AO_RMaBzcP63Uk9PVA <named list [30]>