Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

drive_update

Update an existing Drive file


Description

Update an existing Drive file id with new content ("media" in Drive API-speak), new metadata, or both. To create a new file or update existing, depending on whether the Drive file already exists, see drive_put().

Usage

drive_update(file, media = NULL, ..., verbose = TRUE)

Arguments

file

Something that identifies the file of interest on your Google Drive. Can be a name or path, a file id or URL marked with as_id(), or a dribble.

media

Character, path to the local file to upload.

...

Named parameters to pass along to the Drive API. Has the tidy dots semantics that come from using rlang::list2(). You can affect the metadata of the target file by specifying properties of the Files resource via .... Read the "Request body" section of the Drive API docs for the associated endpoint to learn about relevant parameters.

verbose

Logical, indicating whether to print informative messages (default TRUE).

Value

An object of class dribble, a tibble with one row per item.

See Also

Wraps the files.update endpoint:

This function supports media upload:

Examples

## Not run: 
## Create a new file, so we can update it
x <- drive_upload(drive_example("chicken.csv"))

## Update the file with new media
x <- x %>%
  drive_update(drive_example("chicken.txt"))

## Update the file with new metadata.
## Notice here `name` is not an argument of `drive_update()`, we are passing
## this to the API via the `...``
x <- x %>%
  drive_update(name = "CHICKENS!")

## We can add a parent folder by passing `addParents` via `...`.
folder <- drive_mkdir("second-parent-folder")
x <- x %>%
  drive_update(addParents = as_id(folder))
## Verify the file now has multiple parents
purrr::pluck(x, "drive_resource", 1, "parents")

## Update the file with new media AND new metadata
x <- x %>%
  drive_update(drive_example("chicken.txt"), name = "chicken-poem-again.txt")

## Clean up
drive_rm(x, folder)

## End(Not run)

googledrive

An Interface to Google Drive

v1.0.1
MIT + file LICENSE
Authors
Lucy D'Agostino McGowan [aut], Jennifer Bryan [aut, cre] (<https://orcid.org/0000-0002-6983-2759>), RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.