Fixed: Chinese filename can't upload & add setting-info button

This commit is contained in:
Molunerfinn
2018-01-10 11:31:07 +08:00
parent ca6e72d4fc
commit c6f2e16b80
7 changed files with 123 additions and 29 deletions

View File

@@ -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}`,

View File

@@ -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()