mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-27 11:10:25 +08:00
Fixed: #84 && add multi copy
This commit is contained in:
@@ -50,7 +50,7 @@ const imgFromPath = async (imgPath) => {
|
||||
name = await waitForRename(window, window.webContents.id)
|
||||
}
|
||||
let buffer = await fs.readFile(item)
|
||||
let base64Image = Buffer.from(buffer, 'binary').toString('base64')
|
||||
let base64Image = Buffer.from(buffer).toString('base64')
|
||||
let imgSize = sizeOf(item)
|
||||
results.push({
|
||||
base64Image,
|
||||
@@ -105,7 +105,7 @@ const imgFromUploader = async (files) => {
|
||||
name = await waitForRename(window, window.webContents.id)
|
||||
}
|
||||
let buffer = await fs.readFile(item.path)
|
||||
let base64Image = Buffer.from(buffer, 'binary').toString('base64')
|
||||
let base64Image = Buffer.from(buffer).toString('base64')
|
||||
let imgSize = sizeOf(item.path)
|
||||
results.push({
|
||||
base64Image,
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as img2Base64 from './img2base64'
|
||||
import db from '../../datastore/index'
|
||||
import { Notification, clipboard } from 'electron'
|
||||
import crypto from 'crypto'
|
||||
import mime from 'mime-types'
|
||||
|
||||
// generate COS signature string
|
||||
const generateSignature = (fileName) => {
|
||||
@@ -67,7 +68,7 @@ const postOptions = (fileName, signature, imgBase64) => {
|
||||
headers: {
|
||||
Host: `${options.bucket}.cos.${options.area}.myqcloud.com`,
|
||||
Authorization: `q-sign-algorithm=sha1&q-ak=${options.secretId}&q-sign-time=${signature.signTime}&q-key-time=${signature.signTime}&q-header-list=host&q-url-param-list=&q-signature=${signature.signature}`,
|
||||
contentType: 'multipart/form-data'
|
||||
contentType: mime.lookup(fileName)
|
||||
},
|
||||
body: Buffer.from(imgBase64, 'base64'),
|
||||
resolveWithFullResponse: true
|
||||
|
||||
Reference in New Issue
Block a user