How to use the webdav.createClient function in webdav

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 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 bnankiewicz / organic / src / screens / sources / WebDavSource.tsx View on Github external
const createSourceClient = ({type, password, url, username}: Source) => {
  let client
  switch (type) {
    case 'webdav':
      client = createClient(url, {
        username,
        password,
      })
      break
  }
  return client
}
github RocketChat / Rocket.Chat / app / file-upload / ufs / Webdav / server.js View on Github external
constructor(options) {
		super(options);

		const client = createClient(
			options.connection.credentials.server,
			{
				username: options.connection.credentials.username,
				password: options.connection.credentials.password,
			}
		);

		options.getPath = function(file) {
			if (options.uploadFolderPath[options.uploadFolderPath.length - 1] !== '/') {
				options.uploadFolderPath += '/';
			}
			return options.uploadFolderPath + file._id;
		};

		client.stat(options.uploadFolderPath).catch(function(err) {
			if (err.status === '404') {
github RocketChat / Rocket.Chat / app / webdav / server / methods / getWebdavFileList.js View on Github external
async getWebdavFileList(accountId, path) {
		if (!Meteor.userId()) {
			throw new Meteor.Error('error-invalid-user', 'Invalid User', { method: 'addNewWebdavAccount' });
		}

		if (!settings.get('Webdav_Integration_Enabled')) {
			throw new Meteor.Error('error-not-allowed', 'WebDAV Integration Not Allowed', { method: 'addNewWebdavAccount' });
		}

		const account = WebdavAccounts.findOne({ _id: accountId, user_id: Meteor.userId() });
		if (!account) {
			throw new Meteor.Error('error-invalid-account', 'Invalid WebDAV Account', { method: 'addNewWebdavAccount' });
		}

		const client = createClient(
			account.server_url,
			{
				username: account.username,
				password: account.password,
			}
		);
		try {
			const data = await client.getDirectoryContents(path);
			return { success: true, data };
		} catch (error) {
			return { success: false, message: 'could-not-access-webdav', error };
		}
	},
});
github RocketChat / Rocket.Chat / app / webdav / server / lib / webdavClientAdapter.js View on Github external
constructor(serverConfig, cred) {
		if (cred.token) {
			this._client = createClient(
				serverConfig,
				{ token: cred.token },
			);
		} else {
			this._client = createClient(
				serverConfig,
				{
					username: cred.username,
					password: cred.password,
				},
			);
		}
	}
github buttercup / buttercup-mobile / source / library / remote.js View on Github external
export function getWebDAVConnection(remoteURL, username, password) {
    const webdavClient = username
        ? createWebDAVClient(remoteURL, { username, password })
        : createWebDAVClient(remoteURL);
    return testRemoteFSConnection(webdavClient).then(() => wrapWebDAVClient(webdavClient));
}
github RocketChat / Rocket.Chat / packages / rocketchat-webdav / server / methods / addWebdavAccount.js View on Github external
if (!userId) {
			throw new Meteor.Error('error-invalid-user', 'Invalid User', { method: 'addWebdavAccount' });
		}

		if (!settings.get('Webdav_Integration_Enabled')) {
			throw new Meteor.Error('error-not-allowed', 'WebDAV Integration Not Allowed', { method: 'addWebdavAccount' });
		}

		check(formData, Match.ObjectIncluding({
			serverURL: String,
			username: String,
			pass: String,
		}));

		const client = createClient(
			formData.serverURL,
			{
				username: formData.username,
				password: formData.pass,
			}
		);

		try {
			await client.stat('/');
		} catch (error) {
			return { success: false, message: 'could-not-access-webdav', error };
		}

		const accountData = {
			user_id: userId,
			server_url: formData.serverURL,
github RocketChat / Rocket.Chat / packages / rocketchat-webdav / server / methods / getWebdavFileList.js View on Github external
async getWebdavFileList(accountId, path) {
		if (!Meteor.userId()) {
			throw new Meteor.Error('error-invalid-user', 'Invalid User', { method: 'addNewWebdavAccount' });
		}

		if (!settings.get('Webdav_Integration_Enabled')) {
			throw new Meteor.Error('error-not-allowed', 'WebDAV Integration Not Allowed', { method: 'addNewWebdavAccount' });
		}

		const account = WebdavAccounts.findOne({ _id: accountId, user_id: Meteor.userId() });
		if (!account) {
			throw new Meteor.Error('error-invalid-account', 'Invalid WebDAV Account', { method: 'addNewWebdavAccount' });
		}

		const client = createClient(
			account.server_url,
			{
				username: account.username,
				password: account.password,
			}
		);
		try {
			const data = await client.getDirectoryContents(path);
			return { success: true, data };
		} catch (error) {
			return { success: false, message: 'could-not-access-webdav', error };
		}
	},
});

webdav

WebDAV client for NodeJS

MIT
Latest version published 4 days ago

Package Health Score

80 / 100
Full package analysis