Question

I am running into an error that I have no idea how to deal with. I have require cloudfiles with npm from here: 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);
    });
});

But when I run it I get this error:

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

There is more, but that is probably the important part.

I tried making the path to the local file absolute, starting with ./ or __dirname. I can't figure out what's going wrong.

Was it helpful?

Solution

node-cloudfiles is using a simple, UNIX-y test to determine if a path is absolute or relative:

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

There's an issue about this on GitHub. As noted there, for a workaround, replace vendor/mkdirp.js with https://github.com/substack/node-mkdirp.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top