Personal OneDrive or SharePoint document library
Class representing a personal OneDrive or SharePoint document library.
An R6 object of class ms_drive, inheriting from ms_object.
token: The token used to authenticate with the Graph host.
tenant: The Azure Active Directory tenant for this drive.
type: always "drive" for a drive object.
properties: The drive properties.
new(...): Initialize a new drive object. Do not call this directly; see 'Initialization' below.
delete(confirm=TRUE): Delete a drive. By default, ask for confirmation first.
update(...): Update the drive metadata in Microsoft Graph.
do_operation(...): Carry out an arbitrary operation on the drive.
sync_fields(): Synchronise the R object with the drive metadata in Microsoft Graph.
list_items(...), list_files(...): List the files and folders under the specified path. See 'File and folder operations' below.
download_file(src, dest, overwrite): Download a file.
upload_file(src, dest, blocksize): Upload a file.
create_folder(path): Create a folder.
open_item(path): Open a file or folder.
create_share_link(...): Create a shareable link for a file or folder.
delete_item(path, confirm): Delete a file or folder.
get_item(path): Get an item representing a file or folder.
get_item_properties(path): Get the properties (metadata) for a file or folder.
set_item_properties(path, ...): Set the properties for a file or folder.
This class exposes methods for carrying out common operations on files and folders. They call down to the corresponding methods for the ms_drive_item class. In this context, any paths to child items are relative to the root folder of the drive.
open_item opens the given file or folder in your browser. If the file has an unrecognised type, most browsers will attempt to download it.
list_items(path, info, full_names, pagesize) lists the items under the specified path.
list_files is a synonym for list_items.
download_file and upload_file transfer files between the local machine and the drive. For download_file, the default destination folder is the current (working) directory of your R session. For upload_file, there is no default destination folder; make sure you specify the destination explicitly.
create_folder creates a folder with the specified path. Trying to create an already existing folder is an error.
create_share_link(path, type, expiry, password, scope) returns a shareable link to the item.
delete_item deletes a file or folder. By default, it will ask for confirmation first.
get_item retrieves the file or folder with the given path, as an object of class ms_drive_item.
get_item_properties is a convenience function that returns the properties of a file or folder as a list.
set_item_properties sets the properties of a file or folder. The new properties should be specified as individual named arguments to the method. Any existing properties that aren't listed as arguments will retain their previous values or be recalculated based on changes to other properties, as appropriate. You can also call the update method on the corresponding ms_drive_item object.
## Not run:
# personal OneDrive
mydrv <- get_personal_onedrive()
# OneDrive for Business
busdrv <- get_business_onedrive("mycompany")
# shared document library for a SharePoint site
site <- get_sharepoint_site("My site")
drv <- site$get_drive()
## file/folder operationss
drv$list_files()
drv$list_files("path/to/folder", full_names=TRUE)
# download a file -- default destination filename is taken from the source
drv$download_file("path/to/folder/data.csv")
# shareable links
drv$create_share_link("myfile")
drv$create_share_link("myfile", type="edit", expiry="24 hours")
drv$create_share_link("myfile", password="Use-strong-passwords!")
# file metadata (name, date created, etc)
drv$get_item_properties("myfile")
# rename a file
drv$set_item_properties("myfile", name="newname")
## End(Not run)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.