NOTE: If a function allows you to pass file connections, using a cloud_file
will be a better option for uploading files to OneDrive or SharePoint. See
?cloud_file
for details.
upload_cloud_file(x, writer, file, drive, ...)
upload_sharepoint_file(x, writer, file, ...)
upload_onedrive_file(x, writer, file, ...)
Data object to be written
A function used to the provided data to disk
Destination filepath appropriate for SharePoint or OneDrive
ms_drive object properly connected to OneDrive or SharePoint
Additional parameters to pass to writer
Nothing
These functions handle the necessary process to take a file and place it on
either SharePoint or OneDrive without leaving a local artifact. This is done
by leveraging the automatically created OneDrive and SharePoint ms_drive
objects stored within the m365filer package, but the user may provide
their own ms_drive
object by using upload_cloud_file.
This function works by taking a writer object as a function. For example, if
you want to upload a CSV file to SharePoint, you would provide the data you'd
like to write, then write.csv
into the writer parameter. Note you must pass
the function object itself by not passing in the parentheses. This function
then uses the writer to write out a temporary file, uploads that file to
SharePoint or OneDrive at the path specified in the file
parameter, and
then cleans up after itself.
Note that this function makes a weak assumption about the syntax of the
writer function. It's assumed that the first parameter will be the object
write, and the second object will be the file path for which the file should
be written. This is convention of most writer functions in R, like
write_csv
, write.csv
, writexl::write_xlsx
, and more, but it's not
guaranteed.
For information about how the file path should be specified to properly
assign the destination of your file, see ?ms365_help
.