added resolve to await stream when it is a safari request, updated some comments
This commit is contained in:
@@ -267,8 +267,11 @@ class FileSystemService implements ChunkInterface {
|
||||
// All browsers took many days, tears, and some of my sanity.
|
||||
// Shoutout to Tyzoid for helping me with the decryption
|
||||
// And and helping me understand how the IVs work.
|
||||
// Also fuck you Apple, Safari is turning into
|
||||
// Internet explorer at this point.
|
||||
|
||||
// P.S I hate safari >:(
|
||||
// Why do yall have to be weird with video streaming
|
||||
// 90% of the issues with this are only in Safari
|
||||
// Is safari going to be the next internet explorer?
|
||||
|
||||
const userID = user._id;
|
||||
const currentFile: FileInterface = await dbUtilsFile.getFileInfo(fileID, userID);
|
||||
|
||||
@@ -278,12 +278,19 @@ class MongoService implements ChunkInterface {
|
||||
|
||||
streamVideo = async(user: UserInterface, fileID: string, headers: any, res: Response, req: Request) => {
|
||||
|
||||
// THIS ISN'T WORKING FULLY WHEN USING MONGODB AND SAFARI,
|
||||
// OTHER DATABASES SHOULD WORK, BUT I AM NOT SURE WHY
|
||||
// IT WILL NOT WORK ON SAFARI SOMETIMES
|
||||
|
||||
// To get this all working correctly with encryption and across
|
||||
// All browsers took many days, tears, and some of my sanity.
|
||||
// Shoutout to Tyzoid for helping me with the decryption
|
||||
// And and helping me understand how the IVs work.
|
||||
// Also fuck you Apple, Safari is turning into
|
||||
// Internet explorer at this point.
|
||||
|
||||
// P.S I hate safari >:(
|
||||
// Why do yall have to be weird with video streaming
|
||||
// 90% of the issues with this are only in Safari
|
||||
// Is safari going to be the next internet explorer?
|
||||
|
||||
const userID = user._id;
|
||||
const currentFile = await dbUtilsFile.getFileInfo(fileID, userID);
|
||||
@@ -323,7 +330,11 @@ class MongoService implements ChunkInterface {
|
||||
// 16 bytes.
|
||||
|
||||
fixedStart = 0;
|
||||
fixedEnd = 15;
|
||||
fixedEnd = 16;
|
||||
|
||||
// I am not sure why this needs to be 16 for mongoDB, on the other routes 15 works
|
||||
// Fine, and I thought the start and end were inclusive, but I am really not sure
|
||||
// At this point
|
||||
|
||||
} else {
|
||||
|
||||
@@ -363,7 +374,6 @@ class MongoService implements ChunkInterface {
|
||||
}
|
||||
|
||||
const bucket = new mongoose.mongo.GridFSBucket(conn.db, {
|
||||
chunkSizeBytes: 1024
|
||||
});
|
||||
|
||||
const readStream = bucket.openDownloadStream(new ObjectID(fileID), {
|
||||
@@ -371,19 +381,19 @@ class MongoService implements ChunkInterface {
|
||||
end: fixedEnd,
|
||||
});
|
||||
|
||||
const CIPHER_KEY = crypto.createHash('sha256').update(password).digest()
|
||||
const CIPHER_KEY = crypto.createHash('sha256').update(password).digest()
|
||||
|
||||
res.writeHead(206, head);
|
||||
|
||||
const decipher = crypto.createDecipheriv('aes256', CIPHER_KEY, currentIV);
|
||||
decipher.setAutoPadding(false);
|
||||
|
||||
res.writeHead(206, head);
|
||||
|
||||
const allStreamsToErrorCatch = [readStream, decipher];
|
||||
|
||||
readStream.pipe(decipher);
|
||||
|
||||
await awaitStreamVideo(start, end, differenceStart, decipher, res, req, allStreamsToErrorCatch, readStream);
|
||||
|
||||
|
||||
readStream.destroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -249,8 +249,11 @@ class S3Service implements ChunkInterface {
|
||||
// All browsers took many days, tears, and some of my sanity.
|
||||
// Shoutout to Tyzoid for helping me with the decryption
|
||||
// And and helping me understand how the IVs work.
|
||||
// Also fuck you Apple, Safari is turning into
|
||||
// Internet explorer at this point.
|
||||
|
||||
// P.S I hate safari >:(
|
||||
// Why do yall have to be weird with video streaming
|
||||
// 90% of the issues with this are only in Safari
|
||||
// Is safari going to be the next internet explorer?
|
||||
|
||||
const userID = user._id;
|
||||
const currentFile: FileInterface = await dbUtilsFile.getFileInfo(fileID, userID);
|
||||
|
||||
@@ -38,7 +38,7 @@ const awaitStreamVideo = (start: number, end:number, differenceStart: number,
|
||||
|
||||
if (+start === 0 && +end === 1) {
|
||||
|
||||
// This is for Safri/iOS, for whatever reason they ask for the
|
||||
// This is for Safari/iOS, for whatever reason they ask for the
|
||||
// First byte, but if I actually try to return the first byte
|
||||
// It will not work ???, but if I return the first 4 bytes it seems
|
||||
// To work fine.
|
||||
@@ -52,6 +52,8 @@ const awaitStreamVideo = (start: number, end:number, differenceStart: number,
|
||||
const dataBack = Buffer.from(neededData, "hex");
|
||||
|
||||
res.write(dataBack);
|
||||
|
||||
resolve();
|
||||
})
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user