fix: self review

This commit is contained in:
Apoorv Mishra committed 2023-09-09 08:08:33 +05:30
1 parent 1660036227
commit 5ebbfc6e10
2 files changed
+6 -5

No files matched your search

+6
View File
@@ -10,6 +10,7 @@ import {
import { mkdir, unlink } from "fs/promises";
import path from "path";
import { Readable } from "stream";
import invariant from "invariant";
import JWT from "jsonwebtoken";
import env from "@server/env";
import Logger from "@server/logging/Logger";
@@ -97,6 +98,11 @@ export default class LocalStorage extends BaseStorage {
};
public getFileStream(key: string) {
invariant(
env.FILE_STORAGE_LOCAL_ROOT_DIR,
"FILE_STORAGE_LOCAL_ROOT_DIR is required"
);
const filePath = path.join(env.FILE_STORAGE_LOCAL_ROOT_DIR, key);
return createReadStream(filePath);
}
-5
View File
@@ -175,11 +175,6 @@ export default class S3Storage extends BaseStorage {
}
public async getFileBuffer(key: string) {
invariant(
env.AWS_S3_UPLOAD_BUCKET_NAME,
"AWS_S3_UPLOAD_BUCKET_NAME is required"
);
const stream = this.getFileStream(key);
return new Promise<Buffer>((resolve, reject) => {
const chunks: Buffer[] = [];