Copying file to sharepoint library in R
authentication, r
Solution
Not the most elegant solution but if you're looking to save into a single library on SharePoint, you can first map that library as a drive on your local machine.
Simply use `setwd()` to point to whatever drive letter you mapped the library to. You can then treat that Sharepoint library as if it were any other shared drive location, reading and writing files from/to it.
Problem
I am trying to copy files from a network drive location to a sharepoint library in R. The sharepoint library location requires user authentication and I was wondering how I can copy these files and pass authentication in code. A simple file.copy does not work. I was attempting to use the `getURL()` function from `RCurl` library but that hasn't worked either. I was wondering how I can accomplish this task - copying files while passing authentication. Here are some code snippets that I have tried so far: ``` library(RCurl) from <- "filename" to <- "\\\\sharepoint.company.com\\Directory" #First attempt with just sharepoint location to <- "file://sharepoint.company.com/Directory" #Another attempt with different format h = getCurlHandle(header = TRUE, userpwd = "username:password") getURL(to, verbose = TRUE, curl = h) status <- file.copy(from, to) ``` Thank you!