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.
- package/dist/components/DsBlob.js +22 -8
- package/package.json +1 -1
|
@@ -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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
//-----------------------------------------------------------------------------------------------------------------------------------------
|