Browse Source

add buffer and check base64 is parseable

Gaëtan Renaudeau 4 years ago
parent
commit
a2a41e3d54
No account linked to committer's email address
3 changed files with 20 additions and 1 deletions
  1. 1
    0
      example/package.json
  2. 5
    0
      example/src/Full.js
  3. 14
    1
      example/yarn.lock

+ 1
- 0
example/package.json View File

@@ -11,6 +11,7 @@
11 11
     "@react-native-community/blur": "^3.4.1",
12 12
     "@react-native-community/masked-view": "^0.1.6",
13 13
     "@react-native-community/slider": "^2.0.8",
14
+    "buffer": "^5.4.3",
14 15
     "gl-react": "2",
15 16
     "gl-react-native": "2",
16 17
     "lodash": "^4.17.15",

+ 5
- 0
example/src/Full.js View File

@@ -13,6 +13,7 @@ import {
13 13
   Image,
14 14
 } from 'react-native';
15 15
 
16
+import { Buffer } from 'buffer';
16 17
 import * as ART from '@react-native-community/art';
17 18
 import Slider from '@react-native-community/slider';
18 19
 import omit from 'lodash/omit';
@@ -74,6 +75,10 @@ const App = () => {
74 75
 
75 76
   const onCapture = useCallback(
76 77
     res => {
78
+      if (config.result === 'base64') {
79
+        const b = Buffer.from(res, 'base64');
80
+        console.log('buffer of length ' + b.length);
81
+      }
77 82
       setPreviewSource({
78 83
         uri: config.result === 'base64' ? 'data:image/' + config.format + ';base64,' + res : res,
79 84
       });

+ 14
- 1
example/yarn.lock View File

@@ -1288,7 +1288,7 @@ base-64@^0.1.0:
1288 1288
   resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb"
1289 1289
   integrity sha1-eAqZyE59YAJgNhURxId2E78k9rs=
1290 1290
 
1291
-base64-js@^1.1.2, base64-js@^1.2.3:
1291
+base64-js@^1.0.2, base64-js@^1.1.2, base64-js@^1.2.3:
1292 1292
   version "1.3.1"
1293 1293
   resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1"
1294 1294
   integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==
@@ -1378,6 +1378,14 @@ buffer-from@^1.0.0:
1378 1378
   resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
1379 1379
   integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
1380 1380
 
1381
+buffer@^5.4.3:
1382
+  version "5.4.3"
1383
+  resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.4.3.tgz#3fbc9c69eb713d323e3fc1a895eee0710c072115"
1384
+  integrity sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==
1385
+  dependencies:
1386
+    base64-js "^1.0.2"
1387
+    ieee754 "^1.1.4"
1388
+
1381 1389
 bytes@3.0.0:
1382 1390
   version "3.0.0"
1383 1391
   resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
@@ -2747,6 +2755,11 @@ iconv-lite@^0.4.17, iconv-lite@^0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13:
2747 2755
   dependencies:
2748 2756
     safer-buffer ">= 2.1.2 < 3"
2749 2757
 
2758
+ieee754@^1.1.4:
2759
+  version "1.1.13"
2760
+  resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84"
2761
+  integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==
2762
+
2750 2763
 ignore-walk@^3.0.1:
2751 2764
   version "3.0.1"
2752 2765
   resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8"