shortcut_create | R Documentation |
Creates a shortcut to the target Drive file
, which could be a folder. A
Drive shortcut functions like a symbolic or "soft" link and is primarily
useful for creating a specific Drive user experience in the browser, i.e. to
make a Drive file or folder appear in more than 1 place. Shortcuts are a
relatively new feature in Drive; they were introduced when Drive stopped
allowing a file to have more than 1 parent folder.
shortcut_create(file, path = NULL, name = NULL, overwrite = NA)
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 |
path |
Target destination for the new shortcut, i.e. a folder or a
shared drive. Can be given as an actual path (character), a file id or URL
marked with |
name |
Character, new shortcut name if not specified as part of
|
overwrite |
Logical, indicating whether to check for a pre-existing file
at the targetted "filepath". The quotes around "filepath" refer to the fact
that Drive does not impose a 1-to-1 relationship between filepaths and files,
like a typical file system; read more about that in
Note that existence checks, based on filepath, are expensive operations, i.e. they require additional API calls. |
An object of class dribble
, a tibble with one row per file.
# Target one of the official example files
(src_file <- drive_example_remote("chicken_sheet"))
# Create a shortcut in the default location with the default name
sc1 <- shortcut_create(src_file)
# This shortcut could now be moved, renamed, etc.
# Create a shortcut in the default location with a custom name
sc2 <- src_file %>%
shortcut_create(name = "chicken_sheet_second_shortcut")
# Create a folder, then put a shortcut there, with default name
folder <- drive_mkdir("chicken_sheet_shortcut_folder")
sc3 <- src_file %>%
shortcut_create(folder)
# Look at all these shortcuts
(dat <- drive_find("chicken_sheet", type = "shortcut"))
# Confirm the shortcuts all target the original file
dat <- dat %>%
drive_reveal("shortcut_details")
purrr::map_chr(dat$shortcut_details, "targetId")
as_id(src_file)
# Clean up
drive_rm(sc1, sc2, sc3, folder)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.