datasync-blob 1.1.16 → 1.1.19

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.
@@ -104,13 +104,26 @@ class DsBlob extends _react.Component {
104
104
  //-----------------------------------------------------------------------------------------------------------------------------------------
105
105
  storeBinaryImageToImg = e => {
106
106
  var image = document.createElement('img');
107
- image.onload = this.reduceImage;
107
+ //2Do DEBUG image.onload = this.reduceImage;
108
108
  console.log("storeBinaryImageToImg:e.currentTarget.result = ", e.currentTarget.result);
109
109
  alert("storeBinaryImageToImg !");
110
110
  // Convert ArrayBuffer to Blob URL since image.src cannot accept ArrayBuffer directly
111
- const blob = new Blob([e.currentTarget.result]);
111
+ // Use the detected image type from the original file
112
+ const imageType = this.currentImageType || 'image/jpeg'; // fallback to jpeg
113
+ const blob = new Blob([e.currentTarget.result], {
114
+ type: imageType
115
+ });
112
116
  const blobUrl = URL.createObjectURL(blob);
113
117
  image.src = blobUrl;
118
+
119
+ // Clean up blob URL after image loads to prevent memory leaks
120
+ /* 2Do Debug
121
+ image.onload = (loadEvent) => {
122
+ this.reduceImage(loadEvent);
123
+ URL.revokeObjectURL(blobUrl);
124
+ // Clear the stored image type
125
+ this.currentImageType = null;
126
+ };*/
114
127
  };
115
128
 
116
129
  //-----------------------------------------------------------------------------------------------------------------------------------------
@@ -127,6 +140,10 @@ class DsBlob extends _react.Component {
127
140
  let _reader = new FileReader();
128
141
  console.log("readImageAsBinary:aPictureFile = ", aPictureFile);
129
142
  alert("readImageAsBinary !");
143
+
144
+ // Store the image type for use in storeBinaryImageToImg
145
+ this.currentImageType = aPictureFile.type;
146
+ console.log("Detected image type:", this.currentImageType);
130
147
  _reader.onload = this.storeBinaryImageToImg;
131
148
  _reader.readAsArrayBuffer(aPictureFile); //The readAsArrayBuffer() method reads the file as genuine binary content without base64 conversion.
132
149
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datasync-blob",
3
- "version": "1.1.16",
3
+ "version": "1.1.19",
4
4
  "description": "Datasync Blob component",
5
5
  "main": "./dist/components/DsBlob.js",
6
6
  "files": [