These functions allow for fast and easy transfer between local files and SharePoint, using teams_projects_channel() to retrieve the Projects channel.

download_from_sharepoint(
  remote_file_name = NULL,
  project_number = project_get_current_id(),
  full_sharepoint_path = NULL,
  account = connect_teams(),
  overwrite = TRUE
)

upload_to_sharepoint(
  local_file_name = NULL,
  remote_file_name = NULL,
  project_number = project_get_current_id(),
  full_sharepoint_path = NULL,
  account = connect_teams()
)

source_sharepoint(
  remote_file_name = NULL,
  project_number = project_get_current_id(),
  full_sharepoint_path = NULL,
  account = connect_teams(),
  ...
)

Arguments

remote_file_name

Name of the file to search, will be used together with project_number and can be a regular expression. Will be passed on to project_get_file().

project_number

Planner project number

full_sharepoint_path

Full path of the remote file, consisting of the project folder and the file name, such as "Project - p123/my_file.R".

account

a Microsoft 365 account to use for looking up properties. This has to be an object as returned by connect_teams() or Microsoft365R::get_team().

overwrite

Whether to overwrite an existing file.

local_file_name

File name of the local file.

...

arguments passed on to source()

Details

You must either provide remote_file_name + project_number, or provide full_sharepoint_path.

  • download_from_sharepoint() finds a SharePoint file in the Projects channel using project_get_file(), and downloads it to a local temporary folder. The local filename is returned and can be used in other functions.

  • upload_to_sharepoint() uploads any local file to SharePoint in the Projects channel. The remote path is returned and can be used in other functions.

  • source_sharepoint() runs source() on a SharePoint project file, by downloading it to a temporary folder first using download_from_sharepoint().

Examples

if (FALSE) { # \dontrun{

source_sharepoint(download_from_sharepoint("my_file.R", 123))

"my_file.R" |>
  download_from_sharepoint(project_number = 123) |>
  source_sharepoint()

} # }