transplanted mini_poem for irext console
This commit is contained in:
@@ -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;
|
|
||||||
7
src/web_console/script_npm.sh
Normal file → Executable file
7
src/web_console/script_npm.sh
Normal file → Executable file
@@ -29,9 +29,6 @@ npm install orm
|
|||||||
echo "npm install python-shell"
|
echo "npm install python-shell"
|
||||||
npm install python-shell
|
npm install python-shell
|
||||||
|
|
||||||
echo "npm install oss-client"
|
|
||||||
npm install oss-client
|
|
||||||
|
|
||||||
echo "npm install request"
|
echo "npm install request"
|
||||||
npm install request
|
npm install request
|
||||||
|
|
||||||
@@ -44,7 +41,7 @@ npm install aliyun-sdk
|
|||||||
echo "npm install nodemailer"
|
echo "npm install nodemailer"
|
||||||
npm install nodemailer@0.7
|
npm install nodemailer@0.7
|
||||||
|
|
||||||
echo "npm install ali-oss"
|
echo "npm install node-mysql"
|
||||||
npm install ali-oss
|
npm install mysql
|
||||||
|
|
||||||
echo "npm install done"
|
echo "npm install done"
|
||||||
@@ -11,7 +11,6 @@ var crypto = require('crypto');
|
|||||||
var orm = require('orm');
|
var orm = require('orm');
|
||||||
var Constants = require('../mini_poem/configuration/constants');
|
var Constants = require('../mini_poem/configuration/constants');
|
||||||
var PythonCaller = require('../mini_poem/external/python_caller');
|
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 Category = require('../model/category_dao.js');
|
||||||
var Brand = require('../model/brand_dao.js');
|
var Brand = require('../model/brand_dao.js');
|
||||||
|
|||||||
Reference in New Issue
Block a user