From 1897126d0b7d5bd92bb0c7f3561efddbd66cafa3 Mon Sep 17 00:00:00 2001 From: rajsite Date: Thu, 25 Feb 2021 20:35:16 -0600 Subject: [PATCH] File Base64 fix stackoverflow and Create Data Url --- File/Base64.gcomp/Base64.gcomp | 4 +- File/Base64.gcomp/Create Data Url.gvi | 269 +++++++++++++++ File/Base64.gcomp/Support/Base64.js | 5 +- File/File.gcomp/File Url/Create File Url.gvi | 3 +- File/WebApp.gcomp/index.gviweb | 345 +++++++++++++++---- 5 files changed, 554 insertions(+), 72 deletions(-) create mode 100644 File/Base64.gcomp/Create Data Url.gvi diff --git a/File/Base64.gcomp/Base64.gcomp b/File/Base64.gcomp/Base64.gcomp index ba790fe8..b5664448 100644 --- a/File/Base64.gcomp/Base64.gcomp +++ b/File/Base64.gcomp/Base64.gcomp @@ -1,5 +1,5 @@  - + @@ -26,6 +26,7 @@ + @@ -39,6 +40,7 @@ + diff --git a/File/Base64.gcomp/Create Data Url.gvi b/File/Base64.gcomp/Create Data Url.gvi new file mode 100644 index 00000000..7879fc50 --- /dev/null +++ b/File/Base64.gcomp/Create Data Url.gvi @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + error in + + + + + + + error out + + + + + + + data + + + + + + + content type + + + + data: + + + + string {0} + + + + + ;base64, + + + + string {0} + + + + + + + + data url + + + + + + + + + + + False + 0 + "" + + + + + + + + + + False + 0 + "" + + + + + + + + null + + + image/jpeg + + + "" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/File/Base64.gcomp/Support/Base64.js b/File/Base64.gcomp/Support/Base64.js index 89fc8645..e94bd0f4 100644 --- a/File/Base64.gcomp/Support/Base64.js +++ b/File/Base64.gcomp/Support/Base64.js @@ -2,7 +2,10 @@ 'use strict'; const encode = function (data) { - const binaryString = String.fromCharCode.apply(undefined, data); + let binaryString = ''; + for (let i = 0; i < data.length; i++) { + binaryString += String.fromCharCode(data[i]); + } const encodedData = btoa(binaryString); return encodedData; }; diff --git a/File/File.gcomp/File Url/Create File Url.gvi b/File/File.gcomp/File Url/Create File Url.gvi index a33822c8..0140e2c3 100644 --- a/File/File.gcomp/File Url/Create File Url.gvi +++ b/File/File.gcomp/File Url/Create File Url.gvi @@ -1,5 +1,5 @@  - + @@ -9,6 +9,7 @@ + "<p>Takes a File Reference and creates a file object url. File Object URLs can be used in controls such as the URL Image control. Close File Url must be used to free the file reference.</p>\n\n<p>The benefit of a File Object URL over a data URL is that the VI does not need to load the file content in memory on the diagram. Example use cases are previewing large images or many small images. The trade-off&nbsp;is needing to make sure to cleanup with Close File Url.</p>" diff --git a/File/WebApp.gcomp/index.gviweb b/File/WebApp.gcomp/index.gviweb index 2af951c6..502a8714 100644 --- a/File/WebApp.gcomp/index.gviweb +++ b/File/WebApp.gcomp/index.gviweb @@ -1,5 +1,5 @@  - + @@ -38,11 +38,11 @@ - + - - - + + + @@ -50,13 +50,13 @@ - + - + capture image - + @@ -76,7 +76,7 @@ - + @@ -92,17 +92,17 @@ - + - - - - - captured image + + + + + image blob url - - + + @@ -129,11 +129,11 @@ - + - + @@ -141,8 +141,8 @@ - - + + @@ -154,13 +154,71 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/jpeg + + + + + + + + + image data uri + + + + + + + + + + + + + + - + - + @@ -222,7 +280,7 @@ text file name - + @@ -232,9 +290,9 @@ - + - + @@ -279,7 +337,7 @@ text file name - + @@ -289,9 +347,9 @@ - + - + @@ -351,7 +409,7 @@ - + @@ -362,7 +420,7 @@ - + @@ -372,7 +430,7 @@ - + @@ -381,7 +439,7 @@ - + @@ -419,7 +477,7 @@ - + @@ -438,24 +496,24 @@ save binary - + - + False - + stop - - + + - + - + - + @@ -465,7 +523,7 @@ - + @@ -475,21 +533,25 @@ - - - - + + + +