twikoo-func 1.5.5 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -22
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1425,11 +1425,11 @@ async function uploadImage (event) {
|
|
|
1425
1425
|
}
|
|
1426
1426
|
// tip: qcloud 图床走前端上传,其他图床走后端上传
|
|
1427
1427
|
if (config.IMAGE_CDN === '7bu') {
|
|
1428
|
-
await
|
|
1428
|
+
await uploadImageToLskyPro({ photo, fileName, config, res, imageCdn: 'https://7bu.top' })
|
|
1429
1429
|
} else if (config.IMAGE_CDN === 'smms') {
|
|
1430
1430
|
await uploadImageToSmms({ photo, fileName, config, res })
|
|
1431
1431
|
} else if (isUrl(config.IMAGE_CDN)) {
|
|
1432
|
-
await uploadImageToLskyPro({ photo, fileName, config, res })
|
|
1432
|
+
await uploadImageToLskyPro({ photo, fileName, config, res, imageCdn: config.IMAGE_CDN })
|
|
1433
1433
|
}
|
|
1434
1434
|
} catch (e) {
|
|
1435
1435
|
console.error(e)
|
|
@@ -1439,24 +1439,6 @@ async function uploadImage (event) {
|
|
|
1439
1439
|
return res
|
|
1440
1440
|
}
|
|
1441
1441
|
|
|
1442
|
-
async function uploadImageTo7Bu ({ photo, fileName, config, res }) {
|
|
1443
|
-
// 去不图床旧版本 https://7bu.top
|
|
1444
|
-
// TODO: 2022 年 4 月 30 日后去不图床将会升级新版本,此处逻辑要同步更新
|
|
1445
|
-
const formData = new FormData()
|
|
1446
|
-
formData.append('image', base64UrlToReadStream(photo, fileName))
|
|
1447
|
-
const uploadResult = await axios.post('https://7bu.top/api/upload', formData, {
|
|
1448
|
-
headers: {
|
|
1449
|
-
...formData.getHeaders(),
|
|
1450
|
-
token: config.IMAGE_CDN_TOKEN
|
|
1451
|
-
}
|
|
1452
|
-
})
|
|
1453
|
-
if (uploadResult.data.code === 200) {
|
|
1454
|
-
res.data = uploadResult.data.data
|
|
1455
|
-
} else {
|
|
1456
|
-
throw new Error(uploadResult.data.msg)
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
1442
|
async function uploadImageToSmms ({ photo, fileName, config, res }) {
|
|
1461
1443
|
// SM.MS 图床 https://sm.ms
|
|
1462
1444
|
const formData = new FormData()
|
|
@@ -1474,11 +1456,11 @@ async function uploadImageToSmms ({ photo, fileName, config, res }) {
|
|
|
1474
1456
|
}
|
|
1475
1457
|
}
|
|
1476
1458
|
|
|
1477
|
-
async function uploadImageToLskyPro ({ photo, fileName, config, res }) {
|
|
1459
|
+
async function uploadImageToLskyPro ({ photo, fileName, config, res, imageCdn }) {
|
|
1478
1460
|
// 自定义兰空图床(v2)URL
|
|
1479
1461
|
const formData = new FormData()
|
|
1480
1462
|
formData.append('file', base64UrlToReadStream(photo, fileName))
|
|
1481
|
-
const url = `${
|
|
1463
|
+
const url = `${imageCdn}/api/v1/upload`
|
|
1482
1464
|
let token = config.IMAGE_CDN_TOKEN
|
|
1483
1465
|
if (!token.startsWith('Bearer')) {
|
|
1484
1466
|
token = `Bearer ${token}`
|
package/package.json
CHANGED