Write an object to file and upload file to SharePoint
Source:R/write_sharepoint.R
write_sharepoint.Rd
write_sharepoint()
uses upload_sp_item()
to upload an object created
using:
sf::write_sf()
if x is ansf
objectreadr::write_csv()
if x is adata.frame
and file does not include a xlsx extensionopenxlsx2::write_xlsx()
if x is adata.frame
file does include a xlsx extensionThe
print()
method from{officer}
if x is ardocx
,rpptx
, orrxlsx
objectreadr::write_rds()
if x is any other class
Usage
write_sharepoint(
x,
file,
dest,
...,
.f = NULL,
new_path = tempdir(),
overwrite = FALSE,
drive_name = NULL,
drive_id = NULL,
drive = NULL,
site_url = NULL,
site_name = NULL,
site_id = NULL,
site = NULL,
blocksize = 327680000,
call = caller_env()
)
Arguments
- x
Object to write to file and upload to SharePoint.
sf
,rdocx
,rpptx
,rxlsx
, anddata.frame
objects are saved with the functions noted in the description. All other object types are saved asrds
outputs.- file
File to write to. Passed to
file
parameter forreadr::write_csv()
orreadr::write_rds()
,dsn
forsf::write_sf()
, ortarget
forprint()
(when working with{officer}
class objects).- dest
Destination on SharePoint for file to upload. SharePoint folder URLs are supported.
- ...
Additional parameters passed to write function.
- .f
Optional function to write the input data to disk before uploading file to SharePoint.
- new_path
Path to write file to. Defaults to
tempdir()
- overwrite
If
FALSE
(default), error if an item with the name specified infile
orsrc
already exists at the specified destination. IfTRUE
, overwrite any existing items with the same name. The latter is the default for theupload_file
method.- drive_name, drive_id
SharePoint drive name or ID.
- drive
A
ms_drive
object. If drive is supplied,drive_name
,site_url
, and any additional parameters passed to...
are ignored.- site_url
A SharePoint site URL in the format "https://[tenant name].sharepoint.com/sites/[site name]". Any SharePoint item or document URL can also be parsed to build a site URL using the tenant and site name included in the URL.
- site_name, site_id
Site name or ID of the SharePoint site as an alternative to the SharePoint site URL. Exactly one of
site_url
,site_name
, andsite_id
must be supplied.- site
A
ms_site
object. Ifsite
is supplied,site_url
,site_name
, andsite_id
are ignored.- blocksize
Additional parameter passed to
upload_folder
orupload_file
method forms_drive
objects.- call
The execution environment of a currently running function, e.g.
caller_env()
. The function will be mentioned in error messages as the source of the error. See thecall
argument ofabort()
for more information.