【问题标题】:Error: Relative path uploading to rackspace with node错误:使用节点上传到机架空间的相对路径
【发布时间】:2013-11-14 14:21:54
【问题描述】:

我遇到了一个我不知道如何处理的错误。我从这里需要带有 npm 的云文件:https://npmjs.org/package/cloudfiles

var cf = cloudfiles.createClient({
    auth : {
        username: 'username',
        apiKey: 'xxxxxxx'
    }
});
cf.createContainer('images', function (err, container) {
    client.addFile('images', { remote: '/remoteName.jpg', local: '/maxresdefa.jpg' }, function (err, uploaded) {
      console.log(uploaded);
    });
});

但是当我运行它时,我得到了这个错误:

Error: Relative path: C:\Users\Me\node_modules\cloudfiles\.cache\username at mkdirPSync (C:\Users\Me\node_modules\cloudfiles\vendor\mkbirp.js:22:35)

还有更多,但这可能是重要的部分。

我尝试将本地文件的路径设为绝对路径,以 ./ 或 __dirname 开头。我不知道出了什么问题。

【问题讨论】:

    标签: image node.js upload relative-path rackspace-cloud


    【解决方案1】:

    node-cloudfiles 使用简单的UNIX-y test 来确定路径是绝对路径还是相对路径:

    if (p.charAt(0) != '/') { cb(new Error('Relative path: ' + p)); return }
    

    GitHub 上有一个issue about this。如上所述,要解决此问题,请将 vendor/mkdirp.js 替换为 https://github.com/substack/node-mkdirp

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-06
      • 2018-06-20
      • 2020-05-21
      • 1970-01-01
      • 2016-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多