Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #22 from fengmk2/nfs
Browse files Browse the repository at this point in the history
switchable nfs #21
  • Loading branch information
dead-horse committed Dec 5, 2013
2 parents 6b42c23 + 51307b3 commit 234406e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
24 changes: 6 additions & 18 deletions common/nfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,12 @@
* Module dependencies.
*/

var qn = require('qn');
var config = require('../config');
var nfs = config.nfs;

var client = qn.create(config.qn);
if (!nfs) {
// use qnfs by default
nfs = require('./qnfs');
}

/**
* Upload file
*
* @param {String} filepath
* @param {Object} options
* - {String} key
* - {Number} size
* @param {Function(err, result)} callback
* - {Object} result
* - {String} url
*/
exports.upload = function (filepath, options, callback) {
client.delete(options.key, function (err, data) {
client.uploadFile(filepath, {key: options.key, size: options.size}, callback);
});
};
module.exports = nfs;
37 changes: 37 additions & 0 deletions common/qnfs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*!
* cnpmjs.org - common/qnfs.js
*
* Copyright(c) cnpmjs.org and other contributors.
* MIT Licensed
*
* Authors:
* fengmk2 <[email protected]> (http://fengmk2.github.com)
*/

'use strict';

/**
* Module dependencies.
*/

var qn = require('qn');
var config = require('../config');

var client = qn.create(config.qn);

/**
* Upload file
*
* @param {String} filepath
* @param {Object} options
* - {String} key
* - {Number} size
* @param {Function(err, result)} callback
* - {Object} result
* - {String} url
*/
exports.upload = function (filepath, options, callback) {
client.delete(options.key, function (err, data) {
client.uploadFile(filepath, {key: options.key, size: options.size}, callback);
});
};

0 comments on commit 234406e

Please sign in to comment.