Skip to content

Commit

Permalink
feat!: drop upyun support
Browse files Browse the repository at this point in the history
  • Loading branch information
rocwind committed Feb 9, 2022
1 parent e20f2c6 commit 57bbdc5
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 138 deletions.
85 changes: 0 additions & 85 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"redis": "3.1.2",
"sequelize": "6.16.0",
"slash": "3.0.0",
"upyun": "3.4.4",
"validator": "13.7.0",
"yargs": "17.3.1",
"yazl": "2.5.1"
Expand Down
8 changes: 0 additions & 8 deletions src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ export const config = {
bucketName: process.env.QINIU_BUCKET_NAME,
downloadUrl: process.env.QINIU_DOWNLOAD_URL || process.env.DOWNLOAD_URL,
},
// Config for upyun (https://www.upyun.com/) storage when storageType value is "upyun"
upyun: {
storageDir: process.env.UPYUN_STORAGE_DIR,
serviceName: process.env.UPYUN_SERVICE_NAME,
operatorName: process.env.UPYUN_OPERATOR_NAME,
operatorPass: process.env.UPYUN_OPERATOR_PASS,
downloadUrl: process.env.UPYUN_DOWNLOAD_URL || process.env.DOWNLOAD_URL,
},
// Config for Amazon s3 (https://aws.amazon.com/cn/s3/) storage when storageType value is "s3".
s3: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
Expand Down
44 changes: 0 additions & 44 deletions src/core/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import extract from 'extract-zip';
import _ from 'lodash';
import validator from 'validator';
import qiniu from 'qiniu';
var upyun = require('upyun');
const jschardet = require('jschardet');
import path from 'path';
import util from 'util';
Expand Down Expand Up @@ -225,8 +224,6 @@ common.uploadFileToStorage = function (key, filePath) {
return common.uploadFileToOSS(key, filePath);
} else if (storageType === 'qiniu') {
return common.uploadFileToQiniu(key, filePath);
} else if (storageType === 'upyun') {
return common.uploadFileToUpyun(key, filePath);
} else if (storageType === 'tencentcloud') {
return common.uploadFileToTencentCloud(key, filePath);
}
Expand Down Expand Up @@ -357,47 +354,6 @@ common.uploadFileToQiniu = function (key, filePath) {
});
};

common.uploadFileToUpyun = function (key, filePath) {
var serviceName = _.get(config, 'upyun.serviceName');
var operatorName = _.get(config, 'upyun.operatorName');
var operatorPass = _.get(config, 'upyun.operatorPass', '');
var storageDir = _.get(config, 'upyun.storageDir', '');
var service = new upyun.Service(serviceName, operatorName, operatorPass);
var client = new upyun.Client(service);
return new Promise((resolve, reject) => {
client
.makeDir(storageDir)
.then((result) => {
if (!storageDir) {
reject(new AppError.AppError('Please config the upyun remoteDir!'));
return;
}
let remotePath = storageDir + '/' + key;
logger.debug('uploadFileToUpyun remotePath:', remotePath);
logger.debug('uploadFileToUpyun mkDir result:', result);
client
.putFile(remotePath, fs.createReadStream(filePath))
.then((data) => {
logger.debug('uploadFileToUpyun putFile response:', data);
if (data) {
resolve(key);
} else {
logger.debug('uploadFileToUpyun putFile failed!', data);
reject(new AppError.AppError('Upload file to upyun failed!'));
}
})
.catch((e1) => {
logger.debug('uploadFileToUpyun putFile exception e1:', e1);
reject(new AppError.AppError(JSON.stringify(e1)));
});
})
.catch((e) => {
logger.debug('uploadFileToUpyun putFile exception e:', e);
reject(new AppError.AppError(JSON.stringify(e)));
});
});
};

common.uploadFileToS3 = function (key, filePath) {
var AWS = require('aws-sdk');
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit 57bbdc5

Please sign in to comment.