fixed video streaming

This commit is contained in:
subnub
2024-12-22 19:10:16 -05:00
parent 2e6b7c05f7
commit 634ef88d36
4 changed files with 25 additions and 8 deletions
@@ -383,6 +383,7 @@ class StorageService {
const start = parseInt(parts[0], 10);
const end = parts[1] ? parseInt(parts[1], 10) : fileSize - 1;
const chunksize = end - start + 1;
const IV = currentFile.metadata.IV;
const head = {
"Content-Range": "bytes " + start + "-" + end + "/" + fileSize,
@@ -408,9 +409,25 @@ class StorageService {
fixedStart = 0;
}
let currentIV = IV;
if (fixedStart !== 0 && start !== 0) {
const readStreamParams = createGenericParams({
filePath: currentFile.metadata.filePath,
Key: currentFile.metadata.s3ID,
});
currentIV = (await storageActions.getPrevIV(
readStreamParams,
fixedStart - 16
)) as Buffer;
}
res.writeHead(206, head);
await getFileData(res, fileID, user, { start: fixedStart, end: fixedEnd });
await getFileData(res, fileID, user, currentIV, {
start: fixedStart,
end: fixedEnd,
});
};
getPublicDownload = async (fileID: string, tempToken: any, res: Response) => {
@@ -16,6 +16,7 @@ const proccessData = (
res: Response,
fileID: string,
user: UserInterface,
rangeIV?: Buffer,
range?: { start: number; end: number }
) => {
const eventEmitter = new EventEmitter();
@@ -30,7 +31,7 @@ const proccessData = (
if (!password) throw new ForbiddenError("Invalid Encryption Key");
const IV = currentFile.metadata.IV;
const IV = rangeIV || currentFile.metadata.IV;
const readStreamParams = createGenericParams({
filePath: currentFile.metadata.filePath,
@@ -99,10 +100,11 @@ const getFileData = (
res: Response,
fileID: string,
user: UserInterface,
rangeIV?: Buffer,
range?: { start: number; end: number }
) => {
return new Promise((resolve, reject) => {
const eventEmitter = proccessData(res, fileID, user, range);
const eventEmitter = proccessData(res, fileID, user, rangeIV, range);
eventEmitter.on("finish", (data) => {
resolve(data);
});
+1 -1
View File
@@ -148,7 +148,7 @@ const FolderItem: React.FC<FolderItemProps> = memo((props) => {
</div>
<div
className={classNames(
"overflow-hidden text-ellipsis block w-full animate",
"text-ellipsis block w-full animate",
elementSelected || elementMultiSelected
? "bg-primary text-white"
: "bg-white text-gray-primary"
@@ -118,11 +118,9 @@ const SettingsPageAccount: React.FC<SettingsPageAccountProps> = ({
<p className="text-gray-primary">Email</p>
<p>{user.email}</p>
</div>
{"emailVerified" in user && (
{"emailVerified" in user && !user.emailVerified && (
<div className="px-3 py-4 flex flex-row justify-between items-center border-b border-gray-secondary">
<p className="text-gray-primary">
{user.emailVerified ? "Email verified" : "Email unverified"}
</p>
<p className="text-gray-primary">Email not verified</p>
{!user.emailVerified && (
<button
className="text-primary hover:text-primary-hover cursor-pointer"