fenixedu-drive

1.0.3 • Public • Published

FenixEdu Drive SDK (Node.js)

Add the dependency to your project.

Yarn:

yarn add fenixedu-drive

NPM:

npm install --save fenixedu-drive

Configure SDK Client.

const drive = require("fenixedu-drive");

const client = drive({
	"url": "https://your-fenixedu-drive-url"
	"serviceAppId": "your-service-app-id",
	"serviceAppSecret": "your-service-app-secret",
	"appId": "your-app-id",
	"appSecret": "your-app-secret",
	"username": "the-username-uploading-files"
});

Upload a file to FenixEdu Drive.

...

client.storeFile({
	filename: "my-filename.pdf",
	file: fs.readFileSync("./file.pdf"),
	path: "my/drive/abs/path"
	username: "my-username" // defaults to username in config when omitted
}).then((fileInfo) => {
	// fileInfo is a JSON object like { id: <the-file-id>, path: <file-path-on-drive>,  size: <size-in-bytes> }
}).catch((error) => {
	//handle the error	
});

Download a file from FenixEdu Drive.

...

client.downloadFile({
	fileId: <the-file-id>
}, (err, fileStream) => {
	if(err) {
		throw new Error("Can't download the file");
	} else {
		fileStream.pipe(fs.createWriteStream("./output"));
	}
});

Readme

Keywords

none

Package Sidebar

Install

npm i fenixedu-drive

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • davidmartinho