1
0
mirror of https://github.com/RobinLinus/snapdrop.git synced 2025-05-17 08:00:19 -07:00
This commit is contained in:
RobinLinus 2018-10-11 01:36:28 +02:00
parent aa999e13c5
commit ba69167a76
2 changed files with 3 additions and 4 deletions

View File

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

View File

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