Home

Awesome

node-filesaver

Manage collections of files easily with node.js

Build Status

Installation

Install with npm

$ npm install filesaver

Features

Example

var Filesaver = require( 'filesaver' );

var folders = {
	images: './images'
}

var filesaver = new Filesaver({ folders: folders, safenames: true });

filesaver.add( 'images', ./path/to/file.jpg, 'photo.jpg', function (err, data) {
    console.log( data );
    // => {filename: 'photo_2.jpg', filepath: './images/photo_2.jpg'}
});

Filesaver API

<a name="Filesaver"></a> Filesaver( options )

Filesaver constructor.

Parameters:

Options:

Example:

var folders = {
images: './images',
books: './books'
}
var filesaver = new Filesaver({
folders: folders,
safenames: true
});

<a name="folder"></a> folder( name, path, callback )

Add a new folder

Parameters:

Example:

filesaver.folder( 'documents', './path/to/folder', function () {
// do something
});

<a name="put"></a> put( folder, oldPath, newPath, callback )

Write or overwrite file

Parameters:

Example:

filesaver.put( 'images', '/path/temp/file.jpg', 'photo.jpg', function (err, data) {
console.log( data );
// ->
// filename: 'photo.jpg',
// filepath: './images/photo.jpg'
});

<a name="add"></a> add( folder, oldPath, newPath, callback )

Write a file without overwriting anyone.

Parameters:

Example:

filesaver.add( 'images', '/path/temp/file.jpg', 'photo_1.jpg', function (err, data) {
console.log( data );
// ->
// filename: 'photo_2.jpg',
// filepath: './images/photo_2.jpg'
});

Tests

npm install && npm test

Build API docs

npm install && npm run build-docs

<br><br>


© 2014 jacoborus

Released under MIT License