从R上传文件到SharePoint

4
我正在尝试从R上传文件到SharePoint。我找到了类似的问题,如从R保存文件到SharePoint文件夹使用R将文件保存到SharePoint在R中将文件复制到SharePoint库,但我自己还没有成功。

我尝试过的事情:

system("curl --ntlm --user username:password --upload-file file.xslx https://companyname.sharepoint.com/sites/sitename/Shared%20documents/file.xlsx")

system("curl --ntlm --user username:password --upload-file file.xslx https://companyname.sharepoint.com/sites/sitename/Documents/file.xlsx")

system("curl --ntlm --user username:password --upload-file file.xslx https://companyname.sharepoint.com/sites/sitename/Shared documents/file.xlsx")

system("curl --ntlm --user username:password --upload-file file.xslx \\\\companyname.sharepoint.com@SSL\\sites\\sitename\\Shared%20documents\\file.xlsx")

请注意,我们的SharePoint是使用荷兰语,因此文件夹“Shared documents”在荷兰语中为“Gedeelde documenten”。我尝试了两种语言,但没有成功。不确定我是否应该使用英文名称还是荷兰语名称。
我的猜测是我使用的URL格式不正确,所以我尝试了一些调整,但无法自行找到正确的方法。 非常感谢任何帮助。
编辑: 以下是Sharepoint页面和文件夹的样子。 完整的URL(我猜测从/Forms到结尾的部分不需要在命令中):https://companyname.sharepoint.com/sites/SiteName/Gedeelde%20documenten/Forms/AllItems.aspx?id=%2Fsites%2FOfficeSFMT%2FGedeelde%20documenten%2FGeneral%2FTest 文件夹的截图:foldernames 我的最佳猜测是尝试:"--upload-file C:/Users/UserName/Documents/Test.txt", "companyname.sharepoint.com/sites/SiteName/Documenten/General/Test/Test.txt"

https:// 或 \\ 可能不是必需的。 - RanonKahn
@RanonKahn,我已经尽力了,但似乎还是无法让它正常工作。我编辑了我的问题,所以你可以看到我的文件夹所在的URL以及文件夹的名称。有了那个URL,你会如何尝试解决呢? - Stan
唯一的问题可能是SharePoint访问权限。尝试将其复制到计算机上的其他文件夹或另一个Web文件夹中。 - RanonKahn
问题已在此处得到回答:https://dev59.com/o7roa4cB1Zd3GeqPq8Vy - Esben Eickhardt
1个回答

1
我刚刚测试了以下代码,它可以正常运行:

cmd <- paste("curl --max-time 7200 --connect-timeout 7200 --ntlm --user", "username:password",  "--upload-file Book1.xlsx","teamsites.companyname.com/sites/SandBox/Documents/UserDocumentation/Test/Book1.xlsx", sep = " ")
system(cmd)

我经常使用以下函数。但唯一的问题是,已传输的文件将保持“签出”状态,直到手动“签入”该文件,供他人使用。
saveToSharePoint <- function(fileName) 
  {
   cmd <- paste("curl --max-time 7200 --connect-timeout 7200 --ntlm --user","username:password", 
              "--upload-file", paste0("/home/username/FolderNameWhereTheFileToTransferExists/",fileName), 
              paste0("teamsites.OrganizationName.com/sites/PageTitle/Documents/UserDocumentation/FolderNameWhereTheFileNeedsToBeCopied/",fileName), sep = " ")
   system(cmd)
  }

 saveToSharePoint("SomeFileName.Ext")

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接