Compare commits

..

No commits in common. "db3940f3545c40c8c9b8954a839d71b7eb4162aa" and "b63cdc2c5cfff921cc6ba51b5fd7f9b343018f39" have entirely different histories.

2 changed files with 48 additions and 42 deletions

View File

@ -1,6 +1,6 @@
{
"name": "misskey",
"version": "12.110.1+birb3-1",
"version": "12.110.1+birb3",
"codename": "indigo",
"repository": {
"type": "git",

View File

@ -554,55 +554,61 @@ export function upload(file: File, folder?: any, name?: string, keepOriginal: bo
return new Promise((resolve, reject) => {
const id = Math.random().toString();
const ctx = reactive({
id: id,
name: name || file.name || 'untitled',
progressMax: undefined,
progressValue: undefined,
img: window.URL.createObjectURL(file)
});
const reader = new FileReader();
reader.onload = (e) => {
const ctx = reactive({
id: id,
name: name || file.name || 'untitled',
progressMax: undefined,
progressValue: undefined,
img: window.URL.createObjectURL(file)
});
uploads.value.push(ctx);
uploads.value.push(ctx);
const data = new FormData();
data.append('i', $i.token);
data.append('force', 'true');
data.append('file', file);
console.log(keepOriginal);
if (folder) data.append('folderId', folder);
if (name) data.append('name', name);
const data = new FormData();
data.append('i', $i.token);
data.append('force', 'true');
data.append('file', file);
if (folder) data.append('folderId', folder);
if (name) data.append('name', name);
const xhr = new XMLHttpRequest();
xhr.open('POST', apiUrl + '/drive/files/create', true);
xhr.onload = (ev) => {
if (xhr.status !== 200 || ev.target == null || ev.target.response == null) {
// TODO: 消すのではなくて再送できるようにしたい
uploads.value = uploads.value.filter(x => x.id != id);
alert({
type: 'error',
text: 'upload failed'
});
reject();
return;
}
const driveFile = JSON.parse(ev.target.response);
resolve(driveFile);
const xhr = new XMLHttpRequest();
xhr.open('POST', apiUrl + '/drive/files/create', true);
xhr.onload = (ev) => {
if (xhr.status !== 200 || ev.target == null || ev.target.response == null) {
// TODO: 消すのではなくて再送できるようにしたい
uploads.value = uploads.value.filter(x => x.id != id);
};
alert({
type: 'error',
text: 'upload failed'
});
xhr.upload.onprogress = e => {
if (e.lengthComputable) {
ctx.progressMax = e.total;
ctx.progressValue = e.loaded;
}
};
reject();
return;
}
const driveFile = JSON.parse(ev.target.response);
resolve(driveFile);
uploads.value = uploads.value.filter(x => x.id != id);
xhr.send(data);
};
xhr.upload.onprogress = e => {
if (e.lengthComputable) {
ctx.progressMax = e.total;
ctx.progressValue = e.loaded;
}
};
xhr.send(data);
reader.readAsArrayBuffer(file);
});
}