snapdrop

A Progressive Web App for local file sharing
git clone http://git.hanabi.in/repos/snapdrop.git
Log | Files | Refs | README | LICENSE

commit 73c7430883a92d2f81edbf98d7836d16f8c4457e
parent eee098e723fc4d97b1af692df952d0abde989e07
Author: RobinLinus <robinlinus@users.noreply.github.com>
Date:   Thu, 11 Oct 2018 01:42:20 +0200

Fix multiple bugs on iOS

- receive multiple files
- display videos correctly

Diffstat:
Mclient/scripts/network.js | 5++---
Mclient/scripts/ui.js | 9+++++++--
2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/client/scripts/network.js b/client/scripts/network.js @@ -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 }); } diff --git a/client/scripts/ui.js b/client/scripts/ui.js @@ -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) {