mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-02 11:08:13 -05:00
Fixed: SMMS upload problem
This commit is contained in:
parent
ffbbc74734
commit
a20299edaa
@ -6,12 +6,19 @@ const postOptions = (fileName, imgBase64) => {
|
|||||||
return {
|
return {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `https://sm.ms/api/upload`,
|
url: `https://sm.ms/api/upload`,
|
||||||
formData: {
|
headers: {
|
||||||
smfile: Buffer.from(imgBase64, 'base64'),
|
contentType: 'multipart/form-data',
|
||||||
filename: fileName,
|
'User-Agent': 'PicGo'
|
||||||
ssl: true
|
|
||||||
},
|
},
|
||||||
json: true
|
formData: {
|
||||||
|
smfile: {
|
||||||
|
value: Buffer.from(imgBase64, 'base64'),
|
||||||
|
options: {
|
||||||
|
filename: fileName
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ssl: 'true'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,8 +29,9 @@ const smmsUpload = async function (img, type, webContents) {
|
|||||||
webContents.send('uploadProgress', 30)
|
webContents.send('uploadProgress', 30)
|
||||||
for (let i in imgList) {
|
for (let i in imgList) {
|
||||||
const postConfig = postOptions(imgList[i].fileName, imgList[i].base64Image)
|
const postConfig = postOptions(imgList[i].fileName, imgList[i].base64Image)
|
||||||
const body = await request(postConfig)
|
let body = await request(postConfig)
|
||||||
if (body) {
|
body = JSON.parse(body)
|
||||||
|
if (body.code === 'success') {
|
||||||
delete imgList[i].base64Image
|
delete imgList[i].base64Image
|
||||||
imgList[i]['imgUrl'] = body.data.url
|
imgList[i]['imgUrl'] = body.data.url
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,7 +22,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
confirm () {
|
confirm () {
|
||||||
this.$db.set('picBed.smms', this.form).write()
|
this.$db.set('picBed.smms', true).write()
|
||||||
this.setDefaultPicBed('smms')
|
this.setDefaultPicBed('smms')
|
||||||
const successNotification = new window.Notification('设置结果', {
|
const successNotification = new window.Notification('设置结果', {
|
||||||
body: '设置成功'
|
body: '设置成功'
|
||||||
|
Loading…
Reference in New Issue
Block a user