[Client] Better thumbnail generation

This commit is contained in:
syuilo 2018-11-14 18:00:15 +09:00
parent 4c7dd7228f
commit 840ad75830
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
1 changed files with 1 additions and 7 deletions

View File

@ -57,17 +57,11 @@ export default Vue.extend({
return;
}
// Upload if the file didn't exist yet
const buf = new Uint8Array(e.target.result);
let bin = '';
// We use for-of loop instead of apply() to avoid RangeError
// SEE: https://stackoverflow.com/questions/9267899/arraybuffer-to-base64-encoded-string
for (const byte of buf) bin += String.fromCharCode(byte);
const ctx = {
id: id,
name: file.name || 'untitled',
progress: undefined,
img: 'data:*/*;base64,' + btoa(bin)
img: window.URL.createObjectURL(file)
};
this.uploads.push(ctx);