drive_reveal()
添加了有关您的云端硬盘文件的额外信息,这些信息在 googledrive 生成的默认 dribble
中不易获得。为什么此信息并不总是包含在默认的 dribble
中?
-
你并不总是关心它。
drive_resource
中有很多深奥的信息,对大多数用户来说没有什么值。 -
获取此信息并将其放入可用的形式可能是"expensive"。例如,显示文件的
"path"
、"permissions"
或"published"
状态都需要额外的 API 调用。
当属性名称作为 what
参数传递时,drive_reveal()
还可以将任何属性提升到 drive_resource
列表列之外。如果很容易做到这一点,例如,如果各个元素都是字符串或逻辑元素,则生成的新列会被简化。如果 what
提取日期时间,我们返回 POSIXct
。否则,您将得到一个列表列。如果这让您感到难过,请考虑使用tidyr::hoist()
。由于更丰富的"plucking specification"及其ptype
和transform
参数,它更加强大。另一个有用的函数是tidyr::unnest_wider()
。
参数
- file
-
识别您的 Google 云端硬盘上感兴趣的文件的内容。可以是名称/路径的字符向量、标有
as_id()
的文件 id 或 URL 的字符向量或dribble
。 - what
-
字符,说明您要添加的信息类型。这些值得到特殊处理(更多详细信息如下):
-
path
-
permissions
-
published
-
parent
您还可以按名称请求
drive_resource
列中的任何属性。请求可以位于camelCase
或snake_case
中,但新列名称将始终为snake_case
。what
的一些示例:-
mime_type
(或mimeType
) -
trashed
-
starred
-
description
-
version
-
web_view_link
(或webViewLink
) -
modified_time
(或modifiedTime
) -
created_time
(或createdTime
) -
owned_by_me
(或ownedByMe
) -
size
-
quota_bytes_used
(或quotaBytesUsed
)
-
文件路径
当what = "path"
时,dribble
获得一个包含每个文件路径的字符列。这可能会非常慢,因此请谨慎使用。
示例路径 ~/a/b/
说明了 googledrive 中使用的两个约定:
-
前导
~/
表示文件夹a
位于当前用户的"My Drive" 根文件夹中。 -
尾随
/
表示位于a
中的b
是文件夹或文件夹快捷方式。
权限
当 what = "permissions"
时,dribble
获得指示文件是否共享的逻辑列 shared
以及包含 Permissions resources 列表的新列表列 permissions_resource
。
出版
当 what = "published"
时,dribble
获得指示文件是否已发布的逻辑列 published
以及包含 Revisions resources 列表的新列表列 revision_resource
。
家长
当what = "parent"
时,dribble
获得字符列id_parent
,它是该项目的父文件夹的文件ID。此信息可在 drive_resource
中找到,但不能直接吊出:
-
Google Drive 过去允许文件有多个父项,但现在不再支持,并且 googledrive 现在认为这是不可能的。但是,我们已经看到(非常旧的)文件仍然具有 >1 个父文件夹。如果我们看到这个,我们会发送消息并删除除第一个父级之外的所有父级。
-
drive_resource
中的parents
属性具有"extra" 嵌套层,需要展平。
如果您确实想要原始 parents
属性,请调用 drive_reveal(what = "parents")
。
也可以看看
要了解有关云端硬盘文件元数据中存在的属性(即 dribble
的 drive_resource
列表列中的属性)的更多信息,请参阅 API 文档:
例子
# 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 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv ~/name-squatter-mv 1g5GU11… <named list [39]>
#> 3 name-squatter-upload ~/name-squatter-upload 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename ~/name-squatter-rename 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv ~/name-squatter-mv 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload ~/name-squatter-upload 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename ~/name-squatter-rename 1azGH1O… <named list [39]>
#> 8 name-squatter-mv ~/name-squatter-mv 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload ~/name-squatter-upload 1CtvelV… <named list [39]>
#> 10 name-squatter-rename ~/name-squatter-rename 18sSfXc… <named list [39]>
drive_reveal(files, "permissions")
#> # A dribble: 10 × 5
#> name shared id drive_resource permissions_resource
#> <chr> <lgl> <drv_id> <list> <list>
#> 1 name-squatter-rena… FALSE 1Ms5Vnu… <named list> <named list [2]>
#> 2 name-squatter-mv FALSE 1g5GU11… <named list> <named list [2]>
#> 3 name-squatter-uplo… FALSE 1wtq4ei… <named list> <named list [2]>
#> 4 name-squatter-rena… FALSE 1PIiHD7… <named list> <named list [2]>
#> 5 name-squatter-mv FALSE 1hi9pfU… <named list> <named list [2]>
#> 6 name-squatter-uplo… FALSE 1UVAF7m… <named list> <named list [2]>
#> 7 name-squatter-rena… FALSE 1azGH1O… <named list> <named list [2]>
#> 8 name-squatter-mv FALSE 1ybTgSB… <named list> <named list [2]>
#> 9 name-squatter-uplo… FALSE 1CtvelV… <named list> <named list [2]>
#> 10 name-squatter-rena… FALSE 18sSfXc… <named list> <named list [2]>
drive_reveal(files, "published")
#> # A dribble: 10 × 5
#> name published id drive_resource revision_resource
#> <chr> <lgl> <drv_id> <list> <list>
#> 1 name-squatter-rena… FALSE 1Ms5Vnu… <named list> <named list [9]>
#> 2 name-squatter-mv FALSE 1g5GU11… <named list> <named list [9]>
#> 3 name-squatter-uplo… FALSE 1wtq4ei… <named list> <named list [9]>
#> 4 name-squatter-rena… FALSE 1PIiHD7… <named list> <named list [9]>
#> 5 name-squatter-mv FALSE 1hi9pfU… <named list> <named list [9]>
#> 6 name-squatter-uplo… FALSE 1UVAF7m… <named list> <named list [9]>
#> 7 name-squatter-rena… FALSE 1azGH1O… <named list> <named list [9]>
#> 8 name-squatter-mv FALSE 1ybTgSB… <named list> <named list [9]>
#> 9 name-squatter-uplo… FALSE 1CtvelV… <named list> <named list [9]>
#> 10 name-squatter-rena… FALSE 18sSfXc… <named list> <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 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv 0AO_RMaBzcP63Uk9PVA 1g5GU11… <named list [39]>
#> 3 name-squatter-upload 0AO_RMaBzcP63Uk9PVA 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename 0AO_RMaBzcP63Uk9PVA 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv 0AO_RMaBzcP63Uk9PVA 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload 0AO_RMaBzcP63Uk9PVA 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename 0AO_RMaBzcP63Uk9PVA 1azGH1O… <named list [39]>
#> 8 name-squatter-mv 0AO_RMaBzcP63Uk9PVA 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload 0AO_RMaBzcP63Uk9PVA 1CtvelV… <named list [39]>
#> 10 name-squatter-rename 0AO_RMaBzcP63Uk9PVA 18sSfXc… <named list [39]>
# 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 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv TRUE 1g5GU11… <named list [39]>
#> 3 name-squatter-upload TRUE 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename TRUE 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv TRUE 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload TRUE 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename TRUE 1azGH1O… <named list [39]>
#> 8 name-squatter-mv TRUE 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload TRUE 1CtvelV… <named list [39]>
#> 10 name-squatter-rename TRUE 18sSfXc… <named list [39]>
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 1Ms5Vnu… <named list>
#> 2 name-squatter-mv application/octet-stream 1g5GU11… <named list>
#> 3 name-squatter-upload application/octet-stream 1wtq4ei… <named list>
#> 4 name-squatter-rename application/octet-stream 1PIiHD7… <named list>
#> 5 name-squatter-mv application/octet-stream 1hi9pfU… <named list>
#> 6 name-squatter-upload application/octet-stream 1UVAF7m… <named list>
#> 7 name-squatter-rename application/octet-stream 1azGH1O… <named list>
#> 8 name-squatter-mv application/octet-stream 1ybTgSB… <named list>
#> 9 name-squatter-upload application/octet-stream 1CtvelV… <named list>
#> 10 name-squatter-rename application/octet-stream 18sSfXc… <named list>
drive_reveal(files, "starred")
#> # A dribble: 10 × 4
#> name starred id drive_resource
#> <chr> <lgl> <drv_id> <list>
#> 1 name-squatter-rename FALSE 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv FALSE 1g5GU11… <named list [39]>
#> 3 name-squatter-upload FALSE 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename FALSE 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv FALSE 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload FALSE 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename FALSE 1azGH1O… <named list [39]>
#> 8 name-squatter-mv FALSE 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload FALSE 1CtvelV… <named list [39]>
#> 10 name-squatter-rename FALSE 18sSfXc… <named list [39]>
drive_reveal(files, "description")
#> # A dribble: 10 × 4
#> name description id drive_resource
#> <chr> <list> <drv_id> <list>
#> 1 name-squatter-rename <NULL> 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv <NULL> 1g5GU11… <named list [39]>
#> 3 name-squatter-upload <NULL> 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename <NULL> 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv <NULL> 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload <NULL> 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename <NULL> 1azGH1O… <named list [39]>
#> 8 name-squatter-mv <NULL> 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload <NULL> 1CtvelV… <named list [39]>
#> 10 name-squatter-rename <NULL> 18sSfXc… <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 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv 2 1g5GU11… <named list [39]>
#> 3 name-squatter-upload 2 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename 2 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv 2 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload 2 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename 2 1azGH1O… <named list [39]>
#> 8 name-squatter-mv 2 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload 2 1CtvelV… <named list [39]>
#> 10 name-squatter-rename 2 18sSfXc… <named list [39]>
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/… 1Ms5Vnu… <named list>
#> 2 name-squatter-mv https://drive.google.com/… 1g5GU11… <named list>
#> 3 name-squatter-upload https://drive.google.com/… 1wtq4ei… <named list>
#> 4 name-squatter-rename https://drive.google.com/… 1PIiHD7… <named list>
#> 5 name-squatter-mv https://drive.google.com/… 1hi9pfU… <named list>
#> 6 name-squatter-upload https://drive.google.com/… 1UVAF7m… <named list>
#> 7 name-squatter-rename https://drive.google.com/… 1azGH1O… <named list>
#> 8 name-squatter-mv https://drive.google.com/… 1ybTgSB… <named list>
#> 9 name-squatter-upload https://drive.google.com/… 1CtvelV… <named list>
#> 10 name-squatter-rename https://drive.google.com/… 18sSfXc… <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 2023-06-11 21:30:10 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv 2023-06-11 21:29:48 1g5GU11… <named list [39]>
#> 3 name-squatter-upload 2023-06-11 13:42:46 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename 2023-06-11 13:41:58 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv 2023-06-11 13:41:37 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload 2023-06-10 13:42:03 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename 2023-06-10 13:41:22 1azGH1O… <named list [39]>
#> 8 name-squatter-mv 2023-06-10 13:41:04 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload 2023-06-09 13:42:40 1CtvelV… <named list [39]>
#> 10 name-squatter-rename 2023-06-09 13:42:00 18sSfXc… <named list [39]>
drive_reveal(files, "created_time")
#> # A dribble: 10 × 4
#> name created_time id drive_resource
#> <chr> <dttm> <drv_id> <list>
#> 1 name-squatter-rename 2023-06-11 21:30:10 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv 2023-06-11 21:29:48 1g5GU11… <named list [39]>
#> 3 name-squatter-upload 2023-06-11 13:42:46 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename 2023-06-11 13:41:58 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv 2023-06-11 13:41:37 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload 2023-06-10 13:42:03 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename 2023-06-10 13:41:22 1azGH1O… <named list [39]>
#> 8 name-squatter-mv 2023-06-10 13:41:04 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload 2023-06-09 13:42:40 1CtvelV… <named list [39]>
#> 10 name-squatter-rename 2023-06-09 13:42:00 18sSfXc… <named list [39]>
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 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv TRUE 1g5GU11… <named list [39]>
#> 3 name-squatter-upload TRUE 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename TRUE 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv TRUE 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload TRUE 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename TRUE 1azGH1O… <named list [39]>
#> 8 name-squatter-mv TRUE 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload TRUE 1CtvelV… <named list [39]>
#> 10 name-squatter-rename TRUE 18sSfXc… <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 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv 0 1g5GU11… <named list [39]>
#> 3 name-squatter-upload 0 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename 0 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv 0 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload 0 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename 0 1azGH1O… <named list [39]>
#> 8 name-squatter-mv 0 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload 0 1CtvelV… <named list [39]>
#> 10 name-squatter-rename 0 18sSfXc… <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 1Ms5Vnu… <named list [39]>
#> 2 name-squatter-mv 0 1g5GU11… <named list [39]>
#> 3 name-squatter-upload 0 1wtq4ei… <named list [39]>
#> 4 name-squatter-rename 0 1PIiHD7… <named list [39]>
#> 5 name-squatter-mv 0 1hi9pfU… <named list [39]>
#> 6 name-squatter-upload 0 1UVAF7m… <named list [39]>
#> 7 name-squatter-rename 0 1azGH1O… <named list [39]>
#> 8 name-squatter-mv 0 1ybTgSB… <named list [39]>
#> 9 name-squatter-upload 0 1CtvelV… <named list [39]>
#> 10 name-squatter-rename 0 18sSfXc… <named list [39]>
# '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]>
相关用法
- R googledrive drive_rename 重命名云端硬盘文件
- R googledrive drive_read_string 读取云端硬盘文件的内容
- R googledrive drive_rm 从云端硬盘删除文件
- R googledrive drive_cp 复制云端硬盘文件
- R googledrive drive_mime_type 查找 MIME 类型
- R googledrive drive_id 驱动器 ID 类
- R googledrive drive_auth_configure 编辑和查看身份验证配置
- R googledrive drive_upload 上传到新的云端硬盘文件
- R googledrive drive_mv 移动云端硬盘文件
- R googledrive drive_put 将新媒体放入云端硬盘文件中
- R googledrive drive_has_token 手上有令牌吗?
- R googledrive drive_user 获取当前用户的信息
- R googledrive drive_trash 将云端硬盘文件移入或移出回收站
- R googledrive drive_share 共享云端硬盘文件
- R googledrive drive_about 获取有关云端硬盘函数的信息
- R googledrive drive_update 更新现有云端硬盘文件
- R googledrive drive_mkdir 创建云端硬盘文件夹
- R googledrive drive_fields 请求部分资源
- R googledrive drive_endpoints 列出驱动器端点
- R googledrive drive_deauth 暂停授权
- R googledrive drive_link 检索云端硬盘文件链接
- R googledrive drive_find 在 Google 云端硬盘上查找文件
- R googledrive drive_create 创建一个新的空白云端硬盘文件
- R googledrive drive_examples 示例文件
- R googledrive drive_browse 在浏览器中访问云端硬盘文件
注:本文由纯净天空筛选整理自Jennifer Bryan等大神的英文原创作品 Add a new column of Drive file information。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。