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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。