Skip to content

Commit 456b81c

Browse files
authored
✨ Feature(smms): smms now supports image without token (#89)
1 parent 85ecd16 commit 456b81c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/plugins/uploader/smms.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ const postOptions = (fileName: string, image: Buffer, apiToken: string): Options
2525

2626
const handle = async (ctx: IPicGo): Promise<IPicGo> => {
2727
const smmsConfig = ctx.getConfig<ISmmsConfig>('picBed.smms')
28-
if (!smmsConfig) {
29-
throw new Error('Can\'t find smms config, please provide api token, see https://sm.ms/home/apitoken')
30-
}
3128
const imgList = ctx.output
3229
for (const img of imgList) {
3330
if (img.fileName && img.buffer) {
3431
let image = img.buffer
3532
if (!image && img.base64Image) {
3633
image = Buffer.from(img.base64Image, 'base64')
3734
}
38-
const postConfig = postOptions(img.fileName, image, smmsConfig.token)
35+
const postConfig = postOptions(img.fileName, image, smmsConfig?.token)
3936
let body = await ctx.Request.request(postConfig)
4037
body = JSON.parse(body)
4138
if (body.code === 'success') {

0 commit comments

Comments
 (0)