transplanted mini_poem for irext console

This commit is contained in:
strawmanbobi
2016-12-03 22:38:00 +08:00
parent 65e146f12b
commit f3675a8f11
3 changed files with 3 additions and 78 deletions

View File

@@ -1,71 +0,0 @@
/*
* Created by Strawmanbobi
* 2014-08-30
*/
// 'use strict';
require('../configuration/constants');
var ErrorCode = require('../configuration/error_code');
var Enums = require('../configuration/enums');
var stringUtils = require('../utils/string_utils');
// deprecated
// var AliOSS = require('oss-client');
var AliOSS = require('ali-oss');
var OssWrapper = require('ali-oss').Wrapper;
var logger = require('../logging/logger4js').helper;
var errorCode = new ErrorCode();
var enums = new Enums();
var OSS = function(_region, _bucket, _accessKey, _accessSecret) {
this.option = {
region: _region,
bucket: _bucket,
accessKeyId: _accessKey || OSS_APP_ID,
accessKeySecret: _accessSecret,
};
this.client = new OssWrapper(this.option);
}
OSS.prototype.saveObjectFromBinary = function(objectID, bufferContent, contentType, callback) {
var randomID = stringUtils.randomChar(16);
console.log("object ID = " + objectID);
if(null == objectID) {
objectID = objectID || (null != contentType &&
'' != contentType &&
contentType.indexOf("/") >= 0) ?
randomID + '.' + contentType.substr(contentType.lastIndexOf('/') + 1) :
randomID;
}
this.client.put(objectID, bufferContent).then(function (val) {
console.log('result: %j', val);
callback(errorCode.SUCCESS, objectID);
}).catch (function (err) {
console.log('error: %j', err);
callback(errorCode.FAILED, null);
});
};
OSS.prototype.getObjectByID = function(objectID, filePath, callback) {
this.client.get(objectID, filePath).then(function (val) {
console.log('result: %j', val);
callback(errorCode.SUCCESS, filePath);
}).catch (function (err) {
console.log('error: %j', err);
callback(errorCode.FAILED, null);
});
};
OSS.prototype.serveObjectByID = function(objectID, filePath, callback) {
this.client.get(objectID, filePath).then(function (val) {
console.log('result: %j', val);
callback(errorCode.SUCCESS, filePath);
}).catch (function (err) {
console.log('error: %j', err);
callback(errorCode.FAILED, null);
});
};
module.exports = OSS;

9
src/web_console/script_npm.sh Normal file → Executable file
View File

@@ -29,9 +29,6 @@ npm install orm
echo "npm install python-shell"
npm install python-shell
echo "npm install oss-client"
npm install oss-client
echo "npm install request"
npm install request
@@ -44,7 +41,7 @@ npm install aliyun-sdk
echo "npm install nodemailer"
npm install nodemailer@0.7
echo "npm install ali-oss"
npm install ali-oss
echo "npm install node-mysql"
npm install mysql
echo "npm install done"
echo "npm install done"

View File

@@ -11,7 +11,6 @@ var crypto = require('crypto');
var orm = require('orm');
var Constants = require('../mini_poem/configuration/constants');
var PythonCaller = require('../mini_poem/external/python_caller');
var OSS = require('../mini_poem/data_set/ali_oss.js');
var Category = require('../model/category_dao.js');
var Brand = require('../model/brand_dao.js');