mirror of
https://github.com/doocs/md.git
synced 2024-11-28 13:36:32 +08:00
feat: update cdnHost
This commit is contained in:
parent
9848a76c84
commit
b344d67351
@ -5,6 +5,7 @@ import Buffer from 'buffer-from';
|
||||
import {
|
||||
v4 as uuidv4
|
||||
} from 'uuid';
|
||||
import { resolveConfigFile } from 'prettier';
|
||||
|
||||
const defaultConfig = {
|
||||
username: 'filess',
|
||||
@ -95,10 +96,7 @@ 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;
|
||||
return aliOSSConfig.cdnHost == '' ? res.url : aliOSSConfig.cdnHost + '/' + (aliOSSConfig.path == '' ? dateFilename : dir);
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
@ -120,13 +118,12 @@ async function txCOSFileUpload(file) {
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else if (txCOSConfig.cdnHost) {
|
||||
// if cdnHost exists
|
||||
resolve(txCOSConfig.path != '' ? txCOSConfig.cdnHost + '/' + txCOSConfig.path + '/' + dateFilename : txCOSConfig.cdnHost + '/' + dateFilename);
|
||||
} else {
|
||||
if(txCOSConfig.cdnHost != ''){
|
||||
resolve(txCOSConfig.cdnHost+'/'+txCOSConfig.path + '/' + dateFilename);
|
||||
}else{
|
||||
resolve(data.Location);
|
||||
}
|
||||
|
||||
// if cdnHost not exists
|
||||
reject(data.Location);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
@ -131,7 +131,7 @@ export default {
|
||||
bucket: "",
|
||||
region: "",
|
||||
path: "",
|
||||
cdnHost:""
|
||||
cdnHost: "",
|
||||
},
|
||||
formTxCOS: {
|
||||
secretId: "",
|
||||
@ -139,7 +139,7 @@ export default {
|
||||
bucket: "",
|
||||
region: "",
|
||||
path: "",
|
||||
cdnHost:""
|
||||
cdnHost: "",
|
||||
},
|
||||
options: [{
|
||||
value: "default",
|
||||
|
Loading…
Reference in New Issue
Block a user