How to use @pylonide/jsdav - 10 common examples

To help you get started, we’ve selected a few @pylonide/jsdav examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pylonide / pylon / plugins-server / pylon.fs / fs / file.js View on Github external
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);
        }
github pylonide / pylon / plugins-server / pylon.fs / fs / tree.js View on Github external
copy: function(source, destination, callback) {
    var self = this;
    source = this.getRealPath(source);
    destination = this.getRealPath(destination);
    if (!this.insideSandbox(destination)) {
      return callback(new Exc.Forbidden("You are not allowed to copy to " +
                      this.stripSandbox(destination)));
    }

    // first check if source exists
    this.vfs.stat(source, {}, function(err, stat) {
      if (err || stat.err)
        return callback(err);

      // if destination exists try to delete it
      self.vfs.rmdir(destination, { recursive: true }, function(err) {
        // ignore error because destination may not exists
        self.vfs.execFile("cp", {args: ["-R", source, destination]}, callback);
      });
    });
  },
github pylonide / pylon / plugins-server / pylon.fs / fs / node.js View on Github external
this.vfs.stat(path, {}, function(err, stat) {
      console.log("stat", err, stat);
      if (err || !stat) {
        return callback(new Exc.FileNotFound("File at location "
                        + self.path + " not found"));
      }
      self.$stat = stat;
      callback(null, stat);
    });
  },
github pylonide / pylon / plugins-server / pylon.fs / dav / filewatch.js View on Github external
var Filewatch = module.exports = function(options) {
    var self = this;
    
    var plugin = jsDAV_ServerPlugin.extend({
      initialize: function(handler) {

        jsDAV_ServerPlugin.new(this, handler);

        handler.addEventListener("afterWriteContent", function(e, uri) {
          self.emit("afterWrite", {
            file: "/" + uri
          });
          e.next();
        });

        handler.addEventListener("afterDelete", function(e, uri) {
          self.emit("afterDelete", {
            file: "/" + uri
          });
          e.next();
github pylonide / pylon / plugins-server / pylon.fs / dav / filewatch.js View on Github external
initialize: function(handler) {

        jsDAV_ServerPlugin.new(this, handler);

        handler.addEventListener("afterWriteContent", function(e, uri) {
          self.emit("afterWrite", {
            file: "/" + uri
          });
          e.next();
        });

        handler.addEventListener("afterDelete", function(e, uri) {
          self.emit("afterDelete", {
            file: "/" + uri
          });
          e.next();
        });

        handler.addEventListener("afterMove", function(e, uri) {
github pylonide / pylon / plugins-server / pylon.fs / fs / directory.js View on Github external
this._stat(path, function(err, stat) {
      if (err)
        return callback(new Exc.FileNotFound("File at location " + path + " not found"));

      callback(null, stat.mime == "inode/directory"
                ? new jsDAV_FS_Directory(self.vfs, path, stat)
                : new jsDAV_FS_File(self.vfs, path, stat)
              );
    });
  },
github pylonide / pylon / plugins-server / pylon.fs / fs / tree.js View on Github external
this.vfs.stat(path, {}, function(err, stat) {
      if (err)
        return callback(new Exc.FileNotFound("File at location " + path + " not found"));

      callback(null, stat.mime == "inode/directory"
                ? jsDAV_FS_Directory.new(self.vfs, path, stat)
                : jsDAV_FS_File.new(self.vfs, path, stat)
              );
    });
  },
github pylonide / pylon / plugins-server / pylon.fs / fs / node.js View on Github external
getName: function() {
    return Util.splitPath(this.path)[1];
  },
github pylonide / pylon / plugins-server / pylon.fs / fs / node.js View on Github external
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();
    });
  },
github pylonide / pylon / plugins-server / pylon.fs / dav / permission.js View on Github external
var jsDAV_ServerPlugin = require("@pylonide/jsdav/lib/DAV/plugin");
var util = require("util");

var Permission = module.exports = jsDAV_ServerPlugin.extend({
  /**
   * Plugin name
   *
   * @var String
   */
  name: "permission",

  initialize: function(handler) {
    jsDAV_ServerPlugin.new(this, handler);

    this.handler = handler;
    handler.addEventListener("beforeMethod", this.checkPermission.bind(this));
  },

  READ_METHODS: {
    "OPTIONS":1,

@pylonide/jsdav

jsDAV allows you to easily add WebDAV support to a NodeJS application. jsDAV is meant to cover the entire standard, and attempts to allow integration using an easy to understand API.

MIT
Latest version published 12 months ago

Package Health Score

66 / 100
Full package analysis

Similar packages