當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


R googledrive drive_fields 請求部分資源


您可以通過僅請求實際需要的元數據來提高 API 調用的性能。該函數主要供內部使用,目前主要關注Files resource。請注意,高級 googledrive 函數假定至少包含 nameidkind 字段。假設 resource = "files"(默認值),將根據已知字段名稱檢查通過 fields 提供的輸入的有效性,並返回經過驗證的字段。要查看包含所有可能字段以及每個字段的簡短說明的小標題,請調用 drive_fields(expose())

prep_fields() 準備包含作為查詢參數的字段。

用法

drive_fields(fields = NULL, resource = "files")

prep_fields(fields, resource = "files")

參數

fields

字段名稱的字符向量。如果是resource = "files",則檢查它們的有效性。否則,它們將被通過。

resource

字符,命名感興趣的 API 資源。目前,僅預期文件資源。

drive_fields():字段名稱的字符向量。 prep_fields():一個字符串。

也可以看看

Improve performance,位於 Drive API 文檔中。

例子

# get a tibble of all fields for the Files resource + indicator of defaults
drive_fields(expose())
#> # A tibble: 55 × 2
#>    name                         desc                                      
#>    <chr>                        <chr>                                     
#>  1 appProperties                "A collection of arbitrary key-value pair…
#>  2 capabilities                 "Capabilities the current user has on thi…
#>  3 contentHints                 "Additional information about the content…
#>  4 copyRequiresWriterPermission "Whether the options to copy, print, or d…
#>  5 createdTime                  "The time at which the file was created (…
#>  6 description                  "A short description of the file."        
#>  7 driveId                      "ID of the shared drive the file resides …
#>  8 explicitlyTrashed            "Whether the file has been explicitly tra…
#>  9 exportLinks                  "Links for exporting Google Docs to speci…
#> 10 fileExtension                "The final component of fullFileExtension…
#> # ℹ 45 more rows

# invalid fields are removed and throw warning
drive_fields(c("name", "parents", "ownedByMe", "pancakes!"))
#> Warning: Omitting fields that are not recognized as part of the Files resource:
#> • pancakes!
#> [1] "name"      "parents"   "ownedByMe"

# prepare fields for query
prep_fields(c("name", "parents", "kind"))
#> [1] "files/name,files/parents,files/kind"
源代碼:R/drive_fields.R

相關用法


注:本文由純淨天空篩選整理自Jennifer Bryan等大神的英文原創作品 Request partial resources。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。