无法使用 RCurl 创建文件夹

Unable to create folder with RCurl

我在使用 RCurlftpUpload() 功能将文件上传到 SFTP 中不存在的文件夹时遇到问题。如果该文件夹不存在,我希望使用 ftp.create.missing.dirs 选项创建该文件夹。这是我目前的代码:

.opts <- list(ftp.create.missing.dirs=TRUE)

ftpUpload(what = "test.txt", 
to "sftp://ftp.testserver.com:22/newFolder/existingfile.txt", 
userpwd = paste(user, pwd, sep = ":"), .opts = opts)`

它似乎没有工作,因为我收到以下错误:

* Initialized password authentication
* Authentication complete
* Failed to close libssh2 file

我可以成功地将文件上传到现有文件夹,但当文件夹不存在时我收到错误消息。

问题似乎是由于您正在尝试创建新文件夹,如以下问题所示:Create an remote directory using SFTP / RCurl

错误可在微软R打开git页面找到:

case SSH_SFTP_CLOSE:
  if(sshc->sftp_handle) {
    rc = libssh2_sftp_close(sshc->sftp_handle);
    if(rc == LIBSSH2_ERROR_EAGAIN) {
      break;
    }
    else if(rc < 0) {
      infof(data, "Failed to close libssh2 file\n");
    }
    sshc->sftp_handle = NULL;
  }
  if(sftp_scp)
    Curl_safefree(sftp_scp->path);

在代码中参数 rclibssh2_sftp_close 函数相关(更多信息在这里 https://www.libssh2.org/libssh2_sftp_close_handle.html),它试图关闭不存在的目录,导致错误。

尝试使用 curlPerform 作为:

curlPerform(url="ftp.xxx.xxx.xxx.xxx/";, postquote="MkDir /newFolder/", userpwd="user:pass")