Images now actually send filenames to the server. Server may still disregard them, but pleromer will actually detect mime type properly and generate a sane URL.
This commit is contained in:
parent
9e43a19084
commit
f0ddcb8d6d
|
@ -145,7 +145,7 @@ onmessage = function (e) {
|
||||||
} else if (e.data[0] == 'udg') {
|
} else if (e.data[0] == 'udg') {
|
||||||
udg(e.data[1][0], e.data[1][1])
|
udg(e.data[1][0], e.data[1][1])
|
||||||
} else if (e.data[0] == 'media') {
|
} else if (e.data[0] == 'media') {
|
||||||
media(e.data[1][0], e.data[1][1], e.data[1][2], e.data[1][3])
|
media(e.data[1][0], e.data[1][1], e.data[1][2], e.data[1][3], e.data[1][4])
|
||||||
} else if (e.data[0] == 'post') {
|
} else if (e.data[0] == 'post') {
|
||||||
post('pass')
|
post('pass')
|
||||||
} else if (e.data[0] == 'toastSaved') {
|
} else if (e.data[0] == 'toastSaved') {
|
||||||
|
|
|
@ -156,12 +156,12 @@ ipc.on('resizeJudgement', function (event, b64) {
|
||||||
if (width > resize || height > resize) {
|
if (width > resize || height > resize) {
|
||||||
ipc.send('resize-image', [b64[0], resize])
|
ipc.send('resize-image', [b64[0], resize])
|
||||||
} else {
|
} else {
|
||||||
postMessage(['media', [b64[0], 'image/png', b64[1]]], '*')
|
postMessage(['media', [b64[0], 'image/png', b64[1], null, b64[2]]], '*')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
element.src = 'data:image/png;base64,' + b64[0]
|
element.src = 'data:image/png;base64,' + b64[0]
|
||||||
} else {
|
} else {
|
||||||
postMessage(['media', [b64[0], 'image/png', b64[1]]], '*')
|
postMessage(['media', [b64[0], 'image/png', b64[1], null, b64[2]]], '*')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
//ui,img.js
|
//ui,img.js
|
||||||
|
|
|
@ -57,6 +57,7 @@ function fileselect() {
|
||||||
|
|
||||||
//ファイル読み込み
|
//ファイル読み込み
|
||||||
function handleFileUpload(files, obj, no) {
|
function handleFileUpload(files, obj, no) {
|
||||||
|
console.log('nignog\n'+files+'\n'+obj+'\n'+no)
|
||||||
var fr = new FileReader()
|
var fr = new FileReader()
|
||||||
fr.onload = function(evt) {
|
fr.onload = function(evt) {
|
||||||
var b64 = evt.target.result
|
var b64 = evt.target.result
|
||||||
|
@ -72,21 +73,24 @@ function handleFileUpload(files, obj, no) {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
$('#b64-box').val(b64)
|
$('#b64-box').val(b64)
|
||||||
var ret = media(b64, files['type'], no)
|
var ret = media(b64, files['type'], no, null, files['name'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
element.src = b64
|
element.src = b64
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
$('#b64-box').val(b64)
|
$('#b64-box').val(b64)
|
||||||
var ret = media(b64, files['type'], no)
|
var ret = media(b64, files['type'], no, null, files['name'])
|
||||||
}
|
}
|
||||||
fr.readAsDataURL(files)
|
fr.readAsDataURL(files)
|
||||||
$('#mec').append(files['name'] + '/')
|
$('#mec').append(files['name'] + '/')
|
||||||
}
|
}
|
||||||
|
|
||||||
//ファイルアップロード
|
//ファイルアップロード
|
||||||
async function media(b64, type, no, stamped) {
|
async function media(b64, type, no, stamped, filename) {
|
||||||
|
if (filename) filename=filename.split('/').slice(-1)
|
||||||
|
else filename='image.png' // probably from clipboard
|
||||||
|
console.log('nognig\n'+type+'\n'+no+'\n'+stamped)
|
||||||
var acct_id = $('#post-acct-sel').val()
|
var acct_id = $('#post-acct-sel').val()
|
||||||
var domain = localStorage.getItem('domain_' + acct_id)
|
var domain = localStorage.getItem('domain_' + acct_id)
|
||||||
var user = localStorage.getItem('user_' + acct_id)
|
var user = localStorage.getItem('user_' + acct_id)
|
||||||
|
@ -112,7 +116,7 @@ async function media(b64, type, no, stamped) {
|
||||||
todo('Image Upload...')
|
todo('Image Upload...')
|
||||||
var media = toBlob(b64, type)
|
var media = toBlob(b64, type)
|
||||||
var fd = new FormData()
|
var fd = new FormData()
|
||||||
fd.append('file', media)
|
fd.append('file', media, filename)
|
||||||
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||||
var httpreq = new XMLHttpRequest()
|
var httpreq = new XMLHttpRequest()
|
||||||
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
||||||
|
@ -265,7 +269,7 @@ element.addEventListener('paste', function(e) {
|
||||||
var i = mediav.split(',').length
|
var i = mediav.split(',').length
|
||||||
}
|
}
|
||||||
// DataTransferItem の type に mime tipes があるのでそれを使う
|
// DataTransferItem の type に mime tipes があるのでそれを使う
|
||||||
media(base64, imageType, i)
|
media(base64, imageType, i, null, 'image.png')
|
||||||
}
|
}
|
||||||
fr.readAsDataURL(imageFile)
|
fr.readAsDataURL(imageFile)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ function img(mainWindow, dir) {
|
||||||
for (var i = 0; i < fileNames.length; i++) {
|
for (var i = 0; i < fileNames.length; i++) {
|
||||||
var path = fileNames[i]
|
var path = fileNames[i]
|
||||||
var bin = fs.readFileSync(path, 'base64')
|
var bin = fs.readFileSync(path, 'base64')
|
||||||
e.sender.send('resizeJudgement', [bin, 'new'])
|
e.sender.send('resizeJudgement', [bin, 'new', fileNames[i]])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ipc.on('bmp-image', (e, args) => {
|
ipc.on('bmp-image', (e, args) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user