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(),
  ...
)

download_file_to_sharepoint(
  url,
  local_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() or download.file()

url

URL to download and afterwards upload to SharePoint

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().

  • download_file_to_sharepoint() downloads a remote URL and then uploads the downloaded file to SharePoint using upload_to_sharepoint()

Examples

if (FALSE) { # \dontrun{

source_sharepoint("my_file.R", 123)

"my_file.R" |>
  download_from_sharepoint(project_number = 123) |>
  source_sharepoint()
  
url <- "https://examplefile.com/file-download/26"
from_internet <- download_file_to_sharepoint(url,
                                             "test-download.pdf",
                                             project_number = 123)
from_internet
#> [1] "Testproject - p123/test-download.pdf"

local_file <- download_from_sharepoint(full_sharepoint_path = from_internet)
} # }