How to use webdav - 10 common examples

To help you get started, we’ve selected a few webdav 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 subdavis / Tusk / services / webdavFileManager.js View on Github external
async function searchServer(serverId) {
		let serverInfo = await getServer(serverId)
		if (serverInfo === null) {
			console.error("serverInfo not found");
			return
		}
		let client = createClient(serverInfo.url, serverInfo.username, serverInfo.password)
		createClient.setFetchMethod(window.fetch);

		/** 
		 * returns Object:[]DirInfo
		*/
		let bfs = async function () {
			let queue = ['/']
			let foundDirectories = []

			while (queue.length) {
				let path = queue.shift()

				// TODO: Implement depth better
				if (path.split('/').length > SEARCH_DEPTH)
					break; // We've exceeded search depth
				let contents = await client.getDirectoryContents(path, { credentials: 'omit' });
				let foundKDBXInDir = false;
github Aam-Digital / ndb-core / src / app / webdav / cloud-file-service.service.ts View on Github external
public connect(username: string = null, password: string = null) {
    // clear the promise that retrieves the root dir
    this.currentlyGettingList = null;
    this.fileList = null;

    if (this.sessionService.getCurrentUser() != null) {
      if (username === null && password == null) {
        username = this.sessionService.getCurrentUser().cloudUserName;
        password = this.sessionService.getCurrentUser().cloudPasswordDec;
      }
      this.client = webdav.createClient(
        AppConfig.settings.webdav.remote_url,
        {
          username: username,
          password: password
        }
      );
    }
  }
github RocketChat / Rocket.Chat / app / webdav / server / methods / uploadFileToWebdav.js View on Github external
async uploadFileToWebdav(accountId, fileData, name) {
		const uploadFolder = 'Rocket.Chat Uploads/';
		if (!Meteor.userId()) {
			throw new Meteor.Error('error-invalid-user', 'Invalid User', { method: 'uploadFileToWebdav' });
		}
		if (!settings.get('Webdav_Integration_Enabled')) {
			throw new Meteor.Error('error-not-allowed', 'WebDAV Integration Not Allowed', { method: 'uploadFileToWebdav' });
		}

		const account = WebdavAccounts.findOne({ _id: accountId });
		if (!account) {
			throw new Meteor.Error('error-invalid-account', 'Invalid WebDAV Account', { method: 'uploadFileToWebdav' });
		}
		const client = createClient(
			account.server_url,
			{
				username: account.username,
				password: account.password,
			}
		);
		const future = new Future();

		// create buffer stream from file data
		let bufferStream = new stream.PassThrough();
		if (fileData) {
			bufferStream.end(fileData);
		} else {
			bufferStream = null;
		}
github subdavis / Tusk / services / webdavFileManager.js View on Github external
return getServer(serverId).then(serverInfo => {
			if (serverInfo === null)
				return []
			let client = createClient(serverInfo.url, serverInfo.username, serverInfo.password)
			createClient.setFetchMethod(window.fetch);
			return client.getDirectoryContents(directory, { credentials: 'omit' }).then(contents => {
				// map from directory contents to DBInfo type.
				return contents.filter(element => {
					return element.filename.indexOf('.kdbx') >= 1
				}).map(element => {
					return {
						title: element.basename,
						path: element.filename,
						serverId: serverId
					}
				})
			})
		})
	}
github subdavis / Tusk / services / webdavFileManager.js View on Github external
function addServer(url, username, password) {
		let client = createClient(url, username, password)
		createClient.setFetchMethod((a, b) => {
			return window.fetch(a, b);
		})
		return client.getDirectoryContents('/', { credentials: 'omit' }).then(contents => {
			// success!
			let serverInfo = {
				url: url,
				username: username,
				password: password
			}
			return settings.getSetWebdavServerList().then(serverList => {
				serverList = serverList.length ? serverList : []
				let matches = serverList.filter((elem, i, a) => {
					return (elem.url == serverInfo.url
						&& elem.username == serverInfo.username
						&& elem.password == serverInfo.password)
				})
github avantgardnerio / js-upload-manager / src / main / webapp / src / renderers / FileRenderer.js View on Github external
var createLink = function (text, item, cell, selectedItems) {
            var link = $('<a>');

            // Calculate path
            var path = text.substr(currentPath.length);
            var href = text;
            if (path === '') {
                path = '.';
            }
            if (currentPath.length &gt; text.length) {
                path = '..';
            }
            if (item.getContentType() === File.TYPE.DIRECTORY) {
                href = '#path=' + item.getPath();
                link.click(function () {
                    self.dispatch(new SelectionEvent(item, true));
                });
            }
            var selected = selectedItems.indexOf(item) &gt;= 0;

            // Checkbox
            var checkbox = $('<input>');
            checkbox.attr('type', 'checkbox');
            checkbox.prop('checked', selected);
            checkbox.click(function () {
                var checked = checkbox.prop('checked');
                self.dispatch(new SelectionEvent(item, checked));
            });
            cell.append(checkbox);</a>
github avantgardnerio / js-upload-manager / src / main / webapp / src / webdav / WebDavClient.js View on Github external
var file = new File(response, rootPath);
                if(file.getContentType() === File.TYPE.DIRECTORY) {
                    folders[file.getPath()] = file;
                }
                files.addItem(file);
            });

            // Artificially add the parent folder
            var parentPath = PathUtil.getParentPath(self.getCurrentPath());
            var parentFolder = folders[parentPath];
            if(parentFolder) {
                files.addItem(parentFolder);
            }

            // Sort
            files.sort(File.COMPARATOR);

            return files;
        };
github perry-mitchell / webdav-fs / test / specs / createClient.spc.js View on Github external
it("accepts an agent instance", function(done) {
        const agent = new http.Agent({});
        const client = createClient(
            "http://localhost:" + createServer.test.port + "/webdav/server",
            {
                username: createServer.test.username,
                password: createServer.test.password,
                httpAgent: agent
            }
        );
        client.readdir("/", (err, contents) => {
            expect(err).to.be.null;
            expect(contents).to.have.lengthOf(4);
            done();
        });
    });
});
github perry-mitchell / webdav-fs / test / specs / createClient.spc.js View on Github external
it("accepts an agent instance", function(done) {
        const agent = new http.Agent({});
        const client = createClient(
            "http://localhost:" + createServer.test.port + "/webdav/server",
            {
                username: createServer.test.username,
                password: createServer.test.password,
                httpAgent: agent
            }
        );
        client.readdir("/", (err, contents) => {
            expect(err).to.be.null;
            expect(contents).to.have.lengthOf(4);
            done();
        });
    });
});
github perry-mitchell / webdav-fs / test / specs / index.js View on Github external
function createWebDAVClient() {
    return createClient(
        "http://localhost:" + createServer.test.port + "/webdav/server",
        {
            username: createServer.test.username,
            password: createServer.test.password
        }
    )
}

webdav

WebDAV client for NodeJS

MIT
Latest version published 5 months ago

Package Health Score

80 / 100
Full package analysis