Fix multiple bugs on iOS

- receive multiple files
- display videos correctly
This commit is contained in:
RobinLinus 2018-10-11 01:42:20 +02:00
parent eee098e723
commit 73c7430883
2 changed files with 9 additions and 5 deletions

View file

@ -480,13 +480,12 @@ class FileDigester {
this.progress = this._bytesReceived / this._size;
if (this._bytesReceived < this._size) return;
// we are done
let received = new Blob(this._buffer, { type: this._mime });
let url = URL.createObjectURL(received);
let blob = new Blob(this._buffer, { type: this._mime });
this._callback({
name: this._name,
mime: this._mime,
size: this._size,
url: url
blob: blob
});
}

View file

@ -230,7 +230,8 @@ class ReceiveDialog extends Dialog {
_displayFile(file) {
const $a = this.$el.querySelector('#download');
$a.href = file.url;
const url = URL.createObjectURL(file.blob);
$a.href = url;
$a.download = file.name;
this.$el.querySelector('#fileName').textContent = file.name;
@ -238,7 +239,11 @@ class ReceiveDialog extends Dialog {
this.show();
if (window.isDownloadSupported) return;
// $a.target = "_blank"; // fallback
// fallback for iOS
$a.target = '_blank';
const reader = new FileReader();
reader.onload = e => $a.href = reader.result;
reader.readAsDataURL(file.blob);
}
_formatFileSize(bytes) {