Repository: zeppelin
Updated Branches:
  refs/heads/master f6b58ee5a -> b21f89f6f


[ZEPPELIN-2850] URI Data scheme -> Blob creation

###What is this PR for?

in save-as.service.js, if we use URI Data scheme, we could only contain 2MB 
data in chrome. using the createObjectURL and File API's blob feature, i 
managed to upgrade the capacity to about 900MB. plus this update is better in 
debugging too. if we exceed the 2MB limit in URI data scheme, the download just 
failed with no accurate console log originally, so it was kinda hard to know 
why this happens. But using this technique, if it exceeds the 900MB limit, the 
console log points directly about what the problem is. like this : Uncaught 
RangeError: Failed to construct 'Blob': Array length exceeds supported limit.

https://github.com/apache/zeppelin/blob/master/zeppelin-web/src/app/notebook/save-as/save-as.service.js

###What type of PR is it?

Improvement

###Todos

nothing more i guess

###What is the Jira issue?

https://issues.apache.org/jira/browse/ZEPPELIN-2850

###How should this be tested?

open zeppelin using chrome. make a table by select, then download it by csv or 
tsv. the table should be BIG, like really big, (but not that big for companies, 
which is my case) to test. in the original version if the whole data exceeds 
2MB, you could see that the download fails. but using my script, it doesn't 
fail until it reaches about 900MB~1GB, which is a tremendous improvement.

###Screenshots (if appropriate)

i'll post it later if you really need it. but i'm pretty sure you guys know 
what i'm talking about :)

###Questions:

Does the licenses files need update? no (i guess)
Is there breaking changes for older versions? no
Does this needs documentation? maybe?

Author: imnotkind <billy...@daum.net>

Closes #2532 from imnotkind/master and squashes the following commits:

075c4ec [imnotkind] Update save-as.service.js
db778b1 [imnotkind] Merge pull request #1 from imnotkind/imnotkind-patch-1
e9ad52e [imnotkind] Update save-as.service.js


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/b21f89f6
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/b21f89f6
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/b21f89f6

Branch: refs/heads/master
Commit: b21f89f6fe8dfe209ee6e827b6092c2ae9fe7314
Parents: f6b58ee
Author: imnotkind <billy...@daum.net>
Authored: Thu Aug 17 18:56:31 2017 +0900
Committer: Lee moon soo <m...@apache.org>
Committed: Tue Aug 22 15:18:29 2017 -0700

----------------------------------------------------------------------
 zeppelin-web/src/app/notebook/save-as/save-as.service.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b21f89f6/zeppelin-web/src/app/notebook/save-as/save-as.service.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/save-as/save-as.service.js 
b/zeppelin-web/src/app/notebook/save-as/save-as.service.js
index c71c0f7..ff463c8 100644
--- a/zeppelin-web/src/app/notebook/save-as/save-as.service.js
+++ b/zeppelin-web/src/app/notebook/save-as/save-as.service.js
@@ -38,7 +38,11 @@ function SaveAsService (browserDetectService) {
       }
       angular.element('body > iframe#SaveAsId').remove()
     } else {
-      content = 'data:image/svg;charset=utf-8,' + BOM + 
encodeURIComponent(content)
+      let binaryData = []
+      binaryData.push(BOM)
+      binaryData.push(content)
+      content = window.URL.createObjectURL(new Blob(binaryData))
+
       angular.element('body').append('<a id="SaveAsId"></a>')
       let saveAsElement = angular.element('body > a#SaveAsId')
       saveAsElement.attr('href', content)
@@ -46,6 +50,7 @@ function SaveAsService (browserDetectService) {
       saveAsElement.attr('target', '_blank')
       saveAsElement[0].click()
       saveAsElement.remove()
+      window.URL.revokeObjectURL(content)
     }
   }
 }

Reply via email to