mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-27 19:20:24 +08:00
Fixed: Chinese filename can't upload & add setting-info button
This commit is contained in:
@@ -6,7 +6,7 @@ import { Notification } from 'electron'
|
||||
|
||||
function postOptions (fileName, token, imgBase64) {
|
||||
const area = selectArea(db.read().get('picBed.qiniu.area').value() || 'z0')
|
||||
const base64FileName = Buffer.from(fileName).toString('base64')
|
||||
const base64FileName = Buffer.from(fileName, 'utf-8').toString('base64').replace(/\+/g, '-').replace(/\//g, '_')
|
||||
return {
|
||||
method: 'POST',
|
||||
url: `http://upload${area}.qiniu.com/putb64/-1/key/${base64FileName}`,
|
||||
|
||||
@@ -13,7 +13,7 @@ const generateSignature = (fileName) => {
|
||||
const password = options.password
|
||||
const md5Password = MD5(password)
|
||||
const date = new Date().toGMTString()
|
||||
const uri = `/${options.bucket}/${fileName}`
|
||||
const uri = `/${options.bucket}/${encodeURI(fileName)}`
|
||||
const value = `PUT&${uri}&${date}`
|
||||
const sign = crypto.createHmac('sha1', md5Password).update(value).digest('base64')
|
||||
return `UPYUN ${operator}:${sign}`
|
||||
@@ -24,7 +24,7 @@ const postOptions = (fileName, signature, imgBase64) => {
|
||||
const bucket = options.bucket
|
||||
return {
|
||||
method: 'PUT',
|
||||
url: `https://v0.api.upyun.com/${bucket}/${fileName}`,
|
||||
url: `https://v0.api.upyun.com/${bucket}/${encodeURI(fileName)}`,
|
||||
headers: {
|
||||
Authorization: signature,
|
||||
Date: new Date().toGMTString()
|
||||
|
||||
Reference in New Issue
Block a user