feat(s3): stream s3 content over a zip file (#822)
* chore: update package.json and enhance file handling in backend * refactor: remove StreamResponseFilter and update getZip method for improved file handling - Deleted StreamResponseFilter as it was no longer needed. - Updated getZip method in LocalFileService to return a Promise and handle errors more effectively. - Adjusted getZip method in FileService to await the storage service's getZip call. * refactor: remove unused UseFilters import in file.controller.ts
This commit is contained in:
@@ -14,6 +14,7 @@ import { ConfigService } from "src/config/config.service";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
import { validate as isValidUUID } from "uuid";
|
||||
import { SHARE_DIRECTORY } from "../constants";
|
||||
import { Readable } from "stream";
|
||||
|
||||
@Injectable()
|
||||
export class LocalFileService {
|
||||
@@ -155,7 +156,19 @@ export class LocalFileService {
|
||||
});
|
||||
}
|
||||
|
||||
getZip(shareId: string) {
|
||||
return createReadStream(`${SHARE_DIRECTORY}/${shareId}/archive.zip`);
|
||||
async getZip(shareId: string): Promise<Readable> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const zipStream = createReadStream(
|
||||
`${SHARE_DIRECTORY}/${shareId}/archive.zip`,
|
||||
);
|
||||
|
||||
zipStream.on("error", (err) => {
|
||||
reject(new InternalServerErrorException(err));
|
||||
});
|
||||
|
||||
zipStream.on("open", () => {
|
||||
resolve(zipStream);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user