1.0.3 • Published 9 years ago

fenixedu-drive v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
9 years ago

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"));
	}
});
1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago