datasync-blob 1.1.20 → 1.1.22

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.
@@ -148,16 +148,30 @@ class DsBlob extends _react.Component {
148
148
  context = canvas.getContext('2d');
149
149
  context.drawImage(imageSource, 0, 0, width, height);
150
150
 
151
- //Jpeg conversion
151
+ //Binary conversion using toBlob to maintain binary output
152
152
  let jpegCompressionRatio = this.props.jpegQuality && this.props.jpegQuality > 0 && this.props.jpegQuality < 1 ? this.props.jpegQuality : 1;
153
- let canvasData = canvas.toDataURL('image/jpg', jpegCompressionRatio); //Jpeg conversion
153
+ canvas.toBlob(blob => {
154
+ if (blob) {
155
+ console.log("Binary blob created, size:", blob.size);
156
+ if (this.debugging) console.log("jpegCompressionRatio->", jpegCompressionRatio, " blob.size = ", blob.size);
154
157
 
155
- console.log("canvasData = ", canvasData);
156
- if (this.debugging) console.log("jpegCompressionRatio->", jpegCompressionRatio, " canvasData.length = ", canvasData.length);
157
- this.props.uploadPicture({
158
- data: canvasData ? canvasData : "",
159
- item_id: this.props.item_id
160
- });
158
+ // Convert blob to ArrayBuffer for binary data
159
+ const reader = new FileReader();
160
+ reader.onload = () => {
161
+ const binaryData = reader.result; // ArrayBuffer
162
+ console.log("Binary data ArrayBuffer:", binaryData);
163
+
164
+ // Pass binary data directly to uploadPicture
165
+ this.props.uploadPicture({
166
+ data: binaryData,
167
+ item_id: this.props.item_id
168
+ });
169
+ };
170
+ reader.readAsArrayBuffer(blob);
171
+ } else {
172
+ console.error("Failed to create blob from canvas");
173
+ }
174
+ }, 'image/jpeg', jpegCompressionRatio);
161
175
  };
162
176
 
163
177
  //-----------------------------------------------------------------------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datasync-blob",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "Datasync Blob component",
5
5
  "main": "./dist/components/DsBlob.js",
6
6
  "files": [