still fixing video streaming, issue with canceled request
This commit is contained in:
@@ -193,7 +193,7 @@ class FileSystemService implements ChunkInterface {
|
||||
console.log("Full thumbnail sent");
|
||||
}
|
||||
|
||||
streamVideo = async(user: UserInterface, fileID: string, headers: any, res: Response) => {
|
||||
streamVideo = async(user: UserInterface, fileID: string, headers: any, res: Response, req: Request) => {
|
||||
|
||||
const userID = user._id;
|
||||
const currentFile: FileInterface = await dbUtilsFile.getFileInfo(fileID, userID);
|
||||
@@ -256,6 +256,12 @@ class FileSystemService implements ChunkInterface {
|
||||
|
||||
readStream.pipe(decipher);
|
||||
|
||||
req.on("close", () => {
|
||||
console.log("Destroying read stream");
|
||||
readStream.destroy();
|
||||
console.log("Read Stream Destoryed");
|
||||
})
|
||||
|
||||
await awaitStreamVideo(start, end, differenceStart, decipher, res, allStreamsToErrorCatch);
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class S3Service implements ChunkInterface {
|
||||
|
||||
}
|
||||
|
||||
streamVideo = async(user: UserInterface, fileID: string, headers: any, res: Response) => {
|
||||
streamVideo = async(user: UserInterface, fileID: string, headers: any, res: Response, req: Request) => {
|
||||
|
||||
const userID = user._id;
|
||||
const currentFile: FileInterface = await dbUtilsFile.getFileInfo(fileID, userID);
|
||||
@@ -192,6 +192,12 @@ class S3Service implements ChunkInterface {
|
||||
|
||||
s3ReadStream.pipe(decipher);
|
||||
|
||||
req.on("close", () => {
|
||||
console.log("Destoying read stream");
|
||||
s3ReadStream.destroy();
|
||||
console.log("Read Stream Destroyed");
|
||||
})
|
||||
|
||||
await awaitStreamVideo(start, end, differenceStart, decipher, res, allStreamsToErrorCatch);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ interface ChunkInterface {
|
||||
getThumbnail: (user: UserInterface, id: string) => Promise<Buffer>;
|
||||
getFullThumbnail: (user: UserInterface, fileID: string, res: Response) => void;
|
||||
getPublicDownload: (fileID: string, tempToken: any, res: Response) => void;
|
||||
streamVideo: (user: UserInterface, fileID: string, headers: any, res: Response) => void;
|
||||
streamVideo: (user: UserInterface, fileID: string, headers: any, res: Response, req: Request) => void;
|
||||
}
|
||||
|
||||
export default ChunkInterface;
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Response} from "express"
|
||||
import {Response, Request} from "express"
|
||||
|
||||
const awaitStreamVideo = (start: number, end:number, differenceStart: number,
|
||||
decipher: any, res: Response, streamsToErrorCatch: any[]) => {
|
||||
|
||||
Reference in New Issue
Block a user