datasync-blob 1.1.15 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DsBlob.js +15 -3
- package/package.json +1 -1
|
@@ -93,7 +93,7 @@ class DsBlob extends _react.Component {
|
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
//-----------------------------------------------------------------------------------------------------------------------------------------
|
|
96
|
-
|
|
96
|
+
storeBase64ImageToImg = e => {
|
|
97
97
|
var image = document.createElement('img');
|
|
98
98
|
image.onload = this.reduceImage;
|
|
99
99
|
console.log("storeImageToImg:e.currentTarget.result = ", e.currentTarget.result);
|
|
@@ -101,12 +101,24 @@ class DsBlob extends _react.Component {
|
|
|
101
101
|
image.src = e.currentTarget.result;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
//-----------------------------------------------------------------------------------------------------------------------------------------
|
|
105
|
+
storeBinaryImageToImg = e => {
|
|
106
|
+
var image = document.createElement('img');
|
|
107
|
+
image.onload = this.reduceImage;
|
|
108
|
+
console.log("storeBinaryImageToImg:e.currentTarget.result = ", e.currentTarget.result);
|
|
109
|
+
alert("storeBinaryImageToImg !");
|
|
110
|
+
// Convert ArrayBuffer to Blob URL since image.src cannot accept ArrayBuffer directly
|
|
111
|
+
const blob = new Blob([e.currentTarget.result]);
|
|
112
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
113
|
+
image.src = blobUrl;
|
|
114
|
+
};
|
|
115
|
+
|
|
104
116
|
//-----------------------------------------------------------------------------------------------------------------------------------------
|
|
105
117
|
readImageAsBase64 = async aPictureFile => {
|
|
106
118
|
let _reader = new FileReader();
|
|
107
119
|
console.log("readImageAsBase64:aPictureFile = ", aPictureFile);
|
|
108
120
|
alert("readImageAsBase64 !");
|
|
109
|
-
_reader.onload = this.
|
|
121
|
+
_reader.onload = this.storeBase64ImageToImg;
|
|
110
122
|
_reader.readAsDataURL(aPictureFile); //The readAsDataURL() method of the FileReader interface is used to read the contents of the specified file's data as a base64 encoded string.
|
|
111
123
|
};
|
|
112
124
|
|
|
@@ -115,7 +127,7 @@ class DsBlob extends _react.Component {
|
|
|
115
127
|
let _reader = new FileReader();
|
|
116
128
|
console.log("readImageAsBinary:aPictureFile = ", aPictureFile);
|
|
117
129
|
alert("readImageAsBinary !");
|
|
118
|
-
_reader.onload = this.
|
|
130
|
+
_reader.onload = this.storeBinaryImageToImg;
|
|
119
131
|
_reader.readAsArrayBuffer(aPictureFile); //The readAsArrayBuffer() method reads the file as genuine binary content without base64 conversion.
|
|
120
132
|
};
|
|
121
133
|
|