Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
putStream: function(handler, type, callback) {
var path = this.path;
// is it a chunked upload?
var size = handler.httpRequest.headers["x-file-size"];
if (size && size !== "undefined") {
var parts = Util.splitPath(this.path);
if (!handler.httpRequest.headers["x-file-name"])
handler.httpRequest.headers["x-file-name"] = parts[1];
handler.server.tree.getNodeForPath(parts[0], function(err, parent) {
if (err)
return callback(err);
parent.writeFileChunk(handler, type, callback);
});
}
else {
this.vfs.mkfile(path, {}, function(err, meta) {
if (err) {
if (err.code == "EACCES")
err = new Exc.Forbidden("Permission denied to write file:" + path);
return callback(err);
}
getName: function() {
return Util.splitPath(this.path)[1];
},
setName: function(name, callback) {
var parentPath = Util.splitPath(this.path)[0];
var newName = Util.splitPath(name)[1];
var newPath = parentPath + "/" + newName;
var self = this;
this.vfs.rename(newPath, {from: this.path}, function(err) {
if (err)
return callback(err);
self.path = newPath;
callback();
});
},