Merge pull request #34 from dislazy/master

* close #33
This commit is contained in:
Yang Libin 2020-10-14 23:35:37 +08:00 committed by GitHub
commit 9848a76c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -95,6 +95,9 @@ async function aliOSSFileUpload(content, filename) {
accessKeySecret: aliOSSConfig.accessKeySecret
});
const res = await client.put(dir, buffer);
if(aliOSSConfig.cdnHost != ''){
return aliOSSConfig.cdnHost +'/'+dir;
}
return res.url;
} catch (e) {
return Promise.reject(e);
@ -118,7 +121,12 @@ async function txCOSFileUpload(file) {
if (err) {
reject(err);
} else {
resolve("https://" + data.Location);
if(txCOSConfig.cdnHost != ''){
resolve(txCOSConfig.cdnHost+'/'+txCOSConfig.path + '/' + dateFilename);
}else{
resolve(data.Location);
}
}
});
})

View File

@ -52,6 +52,10 @@
<el-form-item label="Bucket 所在区域" :required="true">
<el-input v-model.trim="formAliOSS.region"
placeholder="如oss-cn-shenzhen"></el-input>
</el-form-item>
<el-form-item label="自定义CDN域名" :required="false">
<el-input v-model.trim="formAliOSS.cdnHost"
placeholder="如https://imagecdn.alidaodao.com"></el-input>
</el-form-item>
<el-form-item label="存储路径">
<el-input v-model.trim="formAliOSS.path"
@ -81,6 +85,10 @@
<el-form-item label="Bucket 所在区域" :required="true">
<el-input v-model.trim="formTxCOS.region"
placeholder="如ap-guangzhou"></el-input>
</el-form-item>
<el-form-item label="自定义CDN域名" :required="false">
<el-input v-model.trim="formTxCOS.cdnHost"
placeholder="如https://imagecdn.alidaodao.com"></el-input>
</el-form-item>
<el-form-item label="存储路径">
<el-input v-model.trim="formTxCOS.path"
@ -122,14 +130,16 @@ export default {
accessKeySecret: "",
bucket: "",
region: "",
path: ""
path: "",
cdnHost:""
},
formTxCOS: {
secretId: "",
secretKey: "",
bucket: "",
region: "",
path: ""
path: "",
cdnHost:""
},
options: [{
value: "default",