diff --git a/src/util.coffee b/src/util.coffee index 8301295..9d97d52 100644 --- a/src/util.coffee +++ b/src/util.coffee @@ -59,20 +59,6 @@ progressText = (progress) -> else txt -# Browser: save a file from ArrayBuffer -browserSaveFile = (mime, name, file) -> - link = document.createElement 'a' - link.style.display = 'none'; - document.body.appendChild link - - blob = new Blob [file], - type: mime - objUrl = URL.createObjectURL blob - - link.href = objUrl - link.download = name - link.click() - # Convert a file size to human-readable form # humanFileSize = (bytes, si) -> @@ -102,6 +88,5 @@ export { isBrowser, isText, progressText, - browserSaveFile, humanFileSize } \ No newline at end of file diff --git a/src/web/fileDecrypter.coffee b/src/web/fileDecrypter.coffee index 19098d0..5e584b6 100644 --- a/src/web/fileDecrypter.coffee +++ b/src/web/fileDecrypter.coffee @@ -19,6 +19,7 @@ class FileDecrypter extends React.Component progress: 0 key: key iv: iv + downloaded: null componentDidMount: -> # Fetch metadata to show to user @@ -60,9 +61,11 @@ class FileDecrypter extends React.Component @setState decrypting: true decrypted = await crypto.decryptFile @state.key, @state.iv, file - util.browserSaveFile @state.mime, @state.name, decrypted + blob = new Blob [decrypted], + type: @state.mime @setState decrypting: false + downloaded: blob render: ->
{ @@ -73,18 +76,31 @@ class FileDecrypter extends React.Component

{@state.name}

{@state.mime}

{util.humanFileSize @state.length}

- else - util.progressText @state.progress - } + # Use an actual link here instead of triggering click + # on a hidden link, because on some browsers it doesn't work + + Save File + + }
}