Use streams to download attachments directly to disk
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
parent
2da49456c6
commit
99b2bc304e
48 changed files with 2297 additions and 356 deletions
|
@ -42,17 +42,28 @@ export async function autoOrientJPEG(
|
|||
// already been scaled to level, oriented, stripped of exif data, and saved
|
||||
// in high quality format. If we want to send the image in HQ we can return
|
||||
// the attachment as-is. Otherwise we'll have to further scale it down.
|
||||
if (!attachment.data || sendHQImages) {
|
||||
const { data, path, size } = attachment;
|
||||
|
||||
if (sendHQImages) {
|
||||
return attachment;
|
||||
}
|
||||
let scaleTarget: string | Blob;
|
||||
if (path) {
|
||||
scaleTarget = window.Signal.Migrations.getAbsoluteAttachmentPath(path);
|
||||
} else {
|
||||
if (!data) {
|
||||
return attachment;
|
||||
}
|
||||
scaleTarget = new Blob([data], {
|
||||
type: attachment.contentType,
|
||||
});
|
||||
}
|
||||
|
||||
const dataBlob = new Blob([attachment.data], {
|
||||
type: attachment.contentType,
|
||||
});
|
||||
try {
|
||||
const { blob: xcodedDataBlob } = await scaleImageToLevel(
|
||||
dataBlob,
|
||||
scaleTarget,
|
||||
attachment.contentType,
|
||||
size,
|
||||
isIncoming
|
||||
);
|
||||
const xcodedDataArrayBuffer = await blobToArrayBuffer(xcodedDataBlob);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue