Skip to content

Commit

Permalink
✨ Feature: add options for tencent cos
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #117
  • Loading branch information
Molunerfinn committed Mar 8, 2022
1 parent 4b93a76 commit 1fccdcc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/plugins/uploader/tcyun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,22 @@ const handle = async (ctx: IPicGo): Promise<IPicGo | boolean> => {
if (body.statusCode === 400) {
throw new Error(body.msg || body.message)
}
const optionUrl = tcYunOptions.options || ''
if (useV4 && body.message === 'SUCCESS') {
delete img.base64Image
delete img.buffer
if (customUrl) {
img.imgUrl = `${customUrl}/${path}${img.fileName}`
} else {
img.imgUrl = body.data.source_url
img.imgUrl = `${body.data.source_url as string}${optionUrl}`
}
} else if (!useV4 && body && body.statusCode === 200) {
delete img.base64Image
delete img.buffer
if (customUrl) {
img.imgUrl = `${customUrl}/${path}${img.fileName}`
img.imgUrl = `${customUrl}/${path}${img.fileName}${optionUrl}`
} else {
img.imgUrl = `https://${tcYunOptions.bucket}.cos.${tcYunOptions.area}.myqcloud.com/${path}${img.fileName}`
img.imgUrl = `https://${tcYunOptions.bucket}.cos.${tcYunOptions.area}.myqcloud.com/${path}${img.fileName}${optionUrl}`
}
} else {
throw new Error(res.body.msg)
Expand Down Expand Up @@ -221,6 +222,12 @@ const config = (ctx: IPicGo): IPluginConfig[] => {
choices: ['v4', 'v5'],
default: 'v5',
required: false
},
{
name: 'options',
type: 'input',
default: userConfig.options || '',
required: false
}
]
return config
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ export interface ITcyunConfig {
customUrl: string
/** COS 版本,v4 或者 v5 */
version: 'v5' | 'v4'
/** 针对图片的一些后缀处理参数 PicGo 2.4.0+ PicGo-Core 1.5.0+ */
options: string
}
/** GitHub 图床配置项 */
export interface IGithubConfig {
Expand Down

0 comments on commit 1fccdcc

Please sign in to comment.