mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
Revert "Replace custom functions with blob-util"
This reverts commit 8a81e9c01bfe80c0e1bf76737092206c06949512.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
const dataURLToBlob = require('blueimp-canvas-to-blob');
|
||||
const MIME = require('./mime');
|
||||
const { arrayBufferToBlob, blobToArrayBuffer } = require('blob-util');
|
||||
const { autoOrientImage } = require('../auto_orient_image');
|
||||
|
||||
// Increment this everytime we change how attachments are processed. This allows us to
|
||||
@@ -24,6 +23,26 @@ const CURRENT_PROCESS_VERSION = 1;
|
||||
// data: ArrayBuffer
|
||||
// }
|
||||
|
||||
// Data type conversion
|
||||
const blobToArrayBuffer = blob =>
|
||||
new Promise((resolve, reject) => {
|
||||
const fileReader = new FileReader();
|
||||
|
||||
fileReader.onload = event =>
|
||||
resolve(event.target.result);
|
||||
|
||||
fileReader.onerror = (event) => {
|
||||
const error = new Error('blobToArrayBuffer: Failed to convert blob');
|
||||
error.cause = event;
|
||||
reject(error);
|
||||
};
|
||||
|
||||
fileReader.readAsArrayBuffer(blob);
|
||||
});
|
||||
|
||||
const arrayBufferToBlob = (arrayBuffer, mimeType) =>
|
||||
new Blob([arrayBuffer], { type: mimeType });
|
||||
|
||||
// Middleware
|
||||
// type ProcessingStep = Attachment -> Promise Attachment
|
||||
|
||||
|
||||
Reference in New Issue
Block a user