【问题标题】:Copying file to sharepoint library in R将文件复制到 R 中的共享点库
【发布时间】:2019-10-17 01:29:55
【问题描述】:

我正在尝试将文件从网络驱动器位置复制到 R 中的共享点库。共享点库位置需要用户身份验证,我想知道如何复制这些文件并在代码中通过身份验证。一个简单的 file.copy 不起作用。我试图使用 RCurl 库中的 getURL() 函数,但这也没有用。我想知道如何完成这项任务 - 在通过身份验证时复制文件。

以下是我目前尝试过的一些代码 sn-ps:

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)

谢谢!

【问题讨论】:

    标签: r authentication


    【解决方案1】:

    不是最优雅的解决方案,但如果您希望保存到 SharePoint 上的单个库中,您可以首先将该库映射为本地计算机上的驱动器。

    只需使用setwd() 指向您将库映射到的任何驱动器号。然后,您可以将该 Sharepoint 库视为任何其他共享驱动器位置,从中读取和写入文件。

    【讨论】:

      【解决方案2】:

      我只是使用以下函数将文件复制到 SharePoint。唯一的问题是,在手动签入文件以供其他人使用之前,传输的文件将保持签出状态。

       saveToSharePoint <- function(fileName) 
         { 
           cmd <- paste("curl --max-time 7200 --connect-timeout 7200 --ntlm --user","username:password", 
                    "--upload-file /home/username/FolderNameWhereTheFileToTransferExists/",fileName, 
                    "teamsites.OrganizationName.com/sites/PageTitle/Documents/UserDocumentation/FolderNameWhereTheFileNeedsToBeCopied/",fileName, sep = " ")
           system(cmd)
         } 
      
       saveToSharePoint("SomeFileName.Ext")
      

      【讨论】:

        【解决方案3】:

        如果您有 SharePoint 在线,您可以导航到该库并单击“同步到计算机”按钮(有一个带箭头的图标和一台计算机)。然后你可以把它作为一个oneDrive并直接写入它。

        【讨论】:

          猜你喜欢
          • 2013-04-01
          • 1970-01-01
          • 1970-01-01
          • 2017-03-20
          • 2020-01-02
          • 1970-01-01
          • 2021-03-09
          • 2022-08-02
          • 2012-05-01
          相关资源
          最近更新 更多