Some refactoring

This commit is contained in:
Raymond Feng 2013-07-01 10:54:53 -07:00
parent 427f270a40
commit 82279ccacb
4 changed files with 14 additions and 5 deletions

View File

@ -1,4 +1,4 @@
var storage = require('../lib/index');
var storage = require('../lib/factory');
var path = require('path');
var rs = storage.createClient({

View File

@ -4,7 +4,7 @@ var express = require('express');
var app = express();
app.configure(function () {
app.set('port', process.env.PORT || 3000);
app.set('port', process.env.PORT || 3001);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());

View File

@ -1,16 +1,25 @@
var factory = require('./index');
var factory = require('./factory');
var IncomingForm = require('formidable');
var StringDecoder = require('string_decoder').StringDecoder;
module.exports = Uploader;
/**
* Constructor
* @param options The client instance or options to create a client
* @returns {Uploader}
* @constructor
*/
function Uploader(options) {
if (!(this instanceof Uploader)) {
return new Uploader(options);
}
this.client = factory.createClient(options);
this.options = options;
if('function' === typeof options) {
this.client = options;
} else {
this.client = factory.createClient(options);
}
}
Uploader.prototype.processUpload = function (req, res, cb) {