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

drive_share

Share Drive files


Description

Grant individuals or other groups access to files, including permission to read, comment, or edit. The returned dribble will have extra columns, shared and permissions_resource. Read more in drive_reveal().

drive_share_anyone() is a convenience wrapper for a common special case: "make this file readable by 'anyone with a link'".

Usage

drive_share(
  file,
  role = c("reader", "commenter", "writer", "fileOrganizer", "owner", "organizer"),
  type = c("user", "group", "domain", "anyone"),
  ...,
  verbose = TRUE
)

drive_share_anyone(file, verbose = TRUE)

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.

role

Character. The role to grant. Must be one of:

  • organizer (applies only to Team Drives)

  • owner

  • fileOrganizer

  • writer

  • commenter

  • reader

type

Character. Describes the grantee. Must be one of:

  • user

  • group

  • domain

  • anyone

...

Name-value pairs to add to the API request. This is where you provide additional information, such as the emailAddress (when grantee type is "group" or "user") or the domain (when grantee type is "domain"). Read the API docs linked below for more details.

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 permissions.create endpoint:

Drive roles and permissions are described here:

Examples

## Not run: 
## Upload a file to share
file <- drive_upload(
   drive_example("chicken.txt"),
   name = "chicken-share.txt",
   type = "document"
)

## Let a specific person comment
file <- file %>%
  drive_share(
    role = "commenter",
    type = "user",
    emailAddress = "susan@example.com"
)

## Let a different specific person edit and customize the email notification
file <- file %>%
  drive_share(
    role = "writer",
    type = "user",
    emailAddress = "carol@example.com",
    emailMessage = "Would appreciate your feedback on this!"
)

## Let anyone read the file
file <- file %>%
  drive_share(role = "reader", type = "anyone")
## Single-purpose wrapper function for this
drive_share_anyone(file)

## Clean up
drive_rm(file)

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