diff --git a/scripts/cos-link.js b/scripts/cos-link.js index 00467651..a2c0afc1 100644 --- a/scripts/cos-link.js +++ b/scripts/cos-link.js @@ -2,7 +2,7 @@ const pkg = require('../package.json') const version = pkg.version // TODO: use the same name format const generateURL = (platform, ext, prefix = 'PicGo-') => { - return `https://picgo-1251750343.cos.ap-chengdu.myqcloud.com/${prefix}${version}${platform}${ext}` + return `https://picgo-1251750343.cos.ap-chengdu.myqcloud.com/${version}/${prefix}${version}${platform}${ext}` } const platformExtList = [ diff --git a/scripts/upload-dist-to-cos.js b/scripts/upload-dist-to-cos.js index 7c3ea769..d55fe93b 100644 --- a/scripts/upload-dist-to-cos.js +++ b/scripts/upload-dist-to-cos.js @@ -10,7 +10,7 @@ const path = require('path') const distPath = path.join(__dirname, '../dist_electron') const BUCKET = 'picgo-1251750343' -const AREA = 'ap-chengdu' +// const AREA = 'ap-chengdu' const VERSION = pkg.version const FILE_PATH = `${VERSION}/` const SECRET_ID = process.env.PICGO_ENV_COS_SECRET_ID @@ -23,14 +23,14 @@ const SECRET_KEY = process.env.PICGO_ENV_COS_SECRET_KEY */ const generateSignature = (fileName, folder = FILE_PATH) => { const secretKey = SECRET_KEY - const area = AREA + // const area = AREA const bucket = BUCKET const path = folder const today = Math.floor(new Date().getTime() / 1000) const tomorrow = today + 86400 const signTime = `${today};${tomorrow}` const signKey = crypto.createHmac('sha1', secretKey).update(signTime).digest('hex') - const httpString = `put\n/${path}${fileName}\n\nhost=${bucket}.cos.${area}.myqcloud.com\n` + const httpString = `put\n/${path}${fileName}\n\nhost=${bucket}.cos.accelerate.myqcloud.com\n` const sha1edHttpString = crypto.createHash('sha1').update(httpString).digest('hex') const stringToSign = `sha1\n${signTime}\n${sha1edHttpString}\n` const signature = crypto.createHmac('sha1', signKey).update(stringToSign).digest('hex') @@ -50,9 +50,9 @@ const generateSignature = (fileName, folder = FILE_PATH) => { const getReqOptions = (fileName, fileBuffer, signature, folder = FILE_PATH) => { return { method: 'PUT', - url: `http://${BUCKET}.cos.${AREA}.myqcloud.com/${encodeURI(folder)}${encodeURI(fileName)}`, + url: `http://${BUCKET}.cos.accelerate.myqcloud.com/${encodeURI(folder)}${encodeURI(fileName)}`, headers: { - Host: `${BUCKET}.cos.${AREA}.myqcloud.com`, + Host: `${BUCKET}.cos.accelerate.myqcloud.com`, Authorization: `q-sign-algorithm=sha1&q-ak=${SECRET_ID}&q-sign-time=${signature.signTime}&q-key-time=${signature.signTime}&q-header-list=host&q-url-param-list=&q-signature=${signature.signature}`, contentType: mime.lookup(fileName), useAgent: `PicGo;${pkg.version};null;null`