Fix: Pleroma image upload

This commit is contained in:
cutls 2020-04-11 10:41:04 +09:00
parent 6ddc613b5a
commit b2564cfabb

View File

@ -133,6 +133,14 @@ async function media(b64, type, no, stamped) {
//v2/media
try {
var id = await v2MediaUpload(domain, at, fd)
if(!id) {
var start = 'https://' + domain + '/api/v1/media'
httpreq.open('POST', start, true)
httpreq.upload.addEventListener('progress', progshow, false)
httpreq.responseType = 'json'
httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
httpreq.send(fd)
} else {
var mediav = $('#media').val()
var regExp = new RegExp('tmp_' + r, 'g')
mediav = mediav.replace(regExp, id)
@ -152,6 +160,7 @@ async function media(b64, type, no, stamped) {
$('#imgup').text('')
$('#imgsel').show()
localStorage.removeItem('image')
}
} catch {
var start = 'https://' + domain + '/api/v1/media'
httpreq.open('POST', start, true)