# 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")
# accessing shared files
shared_df <- drv$list_shared_items()
shared_df$remoteItem[[1]]$open()
shared_items <- drv$list_shared_items(info="items")
shared_items[[1]]$open()
# }
Run the code above in your browser using DataLab