datasync-blob 1.1.16 → 1.1.18

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.
@@ -108,9 +108,21 @@ class DsBlob extends _react.Component {
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
+ image.onload = loadEvent => {
121
+ this.reduceImage(loadEvent);
122
+ URL.revokeObjectURL(blobUrl);
123
+ // Clear the stored image type
124
+ this.currentImageType = null;
125
+ };
114
126
  };
115
127
 
116
128
  //-----------------------------------------------------------------------------------------------------------------------------------------
@@ -127,6 +139,10 @@ class DsBlob extends _react.Component {
127
139
  let _reader = new FileReader();
128
140
  console.log("readImageAsBinary:aPictureFile = ", aPictureFile);
129
141
  alert("readImageAsBinary !");
142
+
143
+ // Store the image type for use in storeBinaryImageToImg
144
+ this.currentImageType = aPictureFile.type;
145
+ console.log("Detected image type:", this.currentImageType);
130
146
  _reader.onload = this.storeBinaryImageToImg;
131
147
  _reader.readAsArrayBuffer(aPictureFile); //The readAsArrayBuffer() method reads the file as genuine binary content without base64 conversion.
132
148
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datasync-blob",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "Datasync Blob component",
5
5
  "main": "./dist/components/DsBlob.js",
6
6
  "files": [