Browser: Fix Safari Blob download issue (#4357)

master
Rushan 8 years ago committed by Dee Koder
parent 1886d94e95
commit a767ad321a
  1. 16
      browser/app/js/actions.js

@ -432,6 +432,8 @@ export const setLoginError = () => {
export const downloadSelected = (url, req, xhr) => { export const downloadSelected = (url, req, xhr) => {
return (dispatch) => { return (dispatch) => {
var anchor = document.createElement('a')
document.body.appendChild(anchor);
xhr.open('POST', url, true) xhr.open('POST', url, true)
xhr.responseType = 'blob' xhr.responseType = 'blob'
@ -439,10 +441,20 @@ export const downloadSelected = (url, req, xhr) => {
if (this.status == 200) { if (this.status == 200) {
dispatch(checkedObjectsReset()) dispatch(checkedObjectsReset())
var blob = new Blob([this.response], { var blob = new Blob([this.response], {
type: 'application/zip' type: 'octet/stream'
}) })
var blobUrl = window.URL.createObjectURL(blob); var blobUrl = window.URL.createObjectURL(blob);
window.location = blobUrl var separator = req.prefix.length > 1 ? '-' : ''
anchor.href = blobUrl
anchor.download = req.bucketName+separator+req.prefix.slice(0, -1)+'.zip';
anchor.click()
window.URL.revokeObjectURL(blobUrl)
anchor.remove()
} }
}; };
xhr.send(JSON.stringify(req)); xhr.send(JSON.stringify(req));

Loading…
Cancel
Save