filebucket

0.0.2 • Public • Published

bucket file storage for node.js

supports

  • Amazon S3

TODO

  • node.js-based server / client
  • rackspace cloudfiles
  • dropbox
  • google drive

Simple Example

 
 
var filebucket = require('filebucket'),
photosBucket = filebucket.client({
    service: 's3',
    key: 'your key',
    secret: 'your secret'
}).bucket("photos");
 
 
photosBucket.putFile('/my/photo.png', '/myRemotePhoto.png', function(error, result) {
    console.log(result.url);//the url of the photo
    console.log(result.service);//the service used
});

Server Example

 
var express = require('express'),
filebucket  = require('filebucket');
 
var server = express.createServer();
 
server.use(filebucket.server({
    username: "user",
    password: "password",
    path: "/filebucket"
}));
 
server.listen(8080);

client:

var fileBucket = require('filebucket'),
var client = filebucket.client({
    type: "filebucket",
    filebucket: {
        username: "user",
        password: "password",
        host: "http://localhost"
    }
})
 
var photosBucket = client.bucket('photos');

API

.get(bucketName, parameters)

returns a bucket representation

  • bucketName - the name of the bucket
  • parameters - the parameters for the given bucket, including what service to use.
//dropbox
var photosBucket = filebucket.client({
    type: 'dropbox',
    dropbox: {
        consumer_key: 'consumer key',
        consumer_secret: 'consumer secret',
        email: 'email',
        password: 'password'
    }
}).client("photos");
 
 
//s3
var photosBucket = filebucket.client({
    type: 's3',
    aws: {
        key: 'consumer key',
        secret: 'consumer secret'
    }
}).bucket("photos");
 
 

bucket.putFile(source, dest, onUpload)

stores a file in the given bucket

  • source - the local, or remote source of the file.
  • dest - the destination of the file
  • onUpload - called when a file is uploaded

bucket.putContent(content, dest, onUpload)

puts content into the destination file

  • content - the file content

bucket.putStream(stream, dest, onUpload)

pipes a stream into the destination file

  • stream - the file stream
var request = require('request');
 
photoBucket.putStream(request.get('http://google.com'), '/google-dump.html', function() {
    //do stuff
});

Stream bucket.get(dest, onFile)

returns the bucket file

Stream bucket.remove(dest, onDelete)

removes the bucket file

Readme

Keywords

none

Package Sidebar

Install

npm i filebucket

Weekly Downloads

0

Version

0.0.2

License

none

Last publish

Collaborators

  • architectd
  • crcn