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
|
@ -13,18 +13,22 @@ export async function uploadAttachment(
|
|||
attachment: AttachmentWithHydratedData
|
||||
): Promise<UploadedAttachmentType> {
|
||||
const keys = getRandomBytes(64);
|
||||
const encrypted = padAndEncryptAttachment(attachment.data, keys);
|
||||
const encrypted = padAndEncryptAttachment({
|
||||
plaintext: attachment.data,
|
||||
keys,
|
||||
});
|
||||
|
||||
const { server } = window.textsecure;
|
||||
strictAssert(server, 'WebAPI must be initialized');
|
||||
|
||||
const cdnKey = await server.putEncryptedAttachment(encrypted.ciphertext);
|
||||
const size = attachment.data.byteLength;
|
||||
|
||||
return {
|
||||
cdnKey,
|
||||
cdnNumber: 2,
|
||||
key: keys,
|
||||
size: attachment.data.byteLength,
|
||||
size,
|
||||
digest: encrypted.digest,
|
||||
|
||||
contentType: MIMETypeToString(attachment.contentType),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue