希望支持aliyunOSS和tencentCos的自定义域名 #33

This commit is contained in:
Jack 2020-10-14 22:47:08 +08:00
parent ee4ad8dcae
commit c3689883a7
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",