fix: Refactor attachment downloads during export to use promises (#5294

* Refactor attachment downloads during export to use promises instead of streams
Date attachments in zip file correctly

* tsc
This commit is contained in:
Tom Moor
2023-05-04 20:20:33 -04:00
committed by GitHub
parent d096ba486f
commit 9942bbee3e
6 changed files with 50 additions and 28 deletions

View File

@@ -13,8 +13,9 @@ import {
import {
publicS3Endpoint,
deleteFromS3,
getFileByKey,
getFileStream,
getSignedUrl,
getFileBuffer,
} from "@server/utils/s3";
import Document from "./Document";
import Team from "./Team";
@@ -75,7 +76,14 @@ class Attachment extends IdModel {
* Get the contents of this attachment as a readable stream.
*/
get stream() {
return getFileByKey(this.key);
return getFileStream(this.key);
}
/**
* Get the contents of this attachment as a buffer.
*/
get buffer() {
return getFileBuffer(this.key);
}
/**

View File

@@ -13,7 +13,7 @@ import {
FileOperationState,
FileOperationType,
} from "@shared/types";
import { deleteFromS3, getFileByKey } from "@server/utils/s3";
import { deleteFromS3, getFileStream } from "@server/utils/s3";
import Collection from "./Collection";
import Team from "./Team";
import User from "./User";
@@ -77,7 +77,7 @@ class FileOperation extends IdModel {
* The file operation contents as a readable stream.
*/
get stream() {
return getFileByKey(this.key);
return getFileStream(this.key);
}
// hooks