From 3f6426c79de772e54c7f0d83847f203aa33c5ecb Mon Sep 17 00:00:00 2001 From: syl Date: Wed, 28 Aug 2019 21:00:36 +0800 Subject: [PATCH 1/6] Revert "repaired oss init error" --- web/dashboard/src/libs/oss.js | 43 ++++++++++------------ web/dashboard/src/views/rn/editPackage.vue | 31 ++-------------- 2 files changed, 22 insertions(+), 52 deletions(-) diff --git a/web/dashboard/src/libs/oss.js b/web/dashboard/src/libs/oss.js index a9f87af..9b4d058 100644 --- a/web/dashboard/src/libs/oss.js +++ b/web/dashboard/src/libs/oss.js @@ -1,31 +1,26 @@ import co from 'co'; import OSS from 'ali-oss'; -const uploadFileToOSS = null; -try{ - const client = new OSS({ - region: process.env.VUE_APP_OSS_REGION, - accessKeyId: process.env.VUE_APP_OSS_KEYID, - accessKeySecret: process.env.VUE_APP_OSS_KEYSECRET, - bucket: process.env.VUE_APP_OSS_BUCKET - }); +const client = new OSS({ + region: process.env.VUE_APP_OSS_REGION, + accessKeyId: process.env.VUE_APP_OSS_KEYID, + accessKeySecret: process.env.VUE_APP_OSS_KEYSECRET, + bucket: process.env.VUE_APP_OSS_BUCKET +}); - this.uploadFileToOSS = (file, fileName = '', callBack, progressCB = null) => { - co(function * () { - let name = fileName === '' ? file.name : fileName; - yield client.multipartUpload(name, file, { - progress: function * (percentage) { - if (progressCB !== null) { progressCB(percentage * 100); } - } - }); - // 上传完成 - let response = yield client.head(name); - callBack(response); - }).catch(() => { +const uploadFileToOSS = (file, fileName = '', callBack, progressCB = null) => { + co(function * () { + let name = fileName === '' ? file.name : fileName; + yield client.multipartUpload(name, file, { + progress: function * (percentage) { + if (progressCB !== null) { progressCB(percentage * 100); } + } }); - }; -}catch (e) { - console.log(e) -} + // 上传完成 + let response = yield client.head(name); + callBack(response); + }).catch(() => { + }); +}; export default uploadFileToOSS; diff --git a/web/dashboard/src/views/rn/editPackage.vue b/web/dashboard/src/views/rn/editPackage.vue index 75ff27e..b69a008 100644 --- a/web/dashboard/src/views/rn/editPackage.vue +++ b/web/dashboard/src/views/rn/editPackage.vue @@ -1,7 +1,7 @@ -