-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4728 from MBR-0001/subtitle-improvements-2
Add ability to upload hearing-impaired subs
- Loading branch information
Showing
4 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Reads and returns the file encoded in base64 | ||
*/ | ||
export function readFileAsBase64(file: File): Promise<string> { | ||
return new Promise(function (resolve, reject) { | ||
const reader = new FileReader(); | ||
reader.onload = (e) => { | ||
// Split by a comma to remove the url: prefix | ||
const data = (e.target?.result as string)?.split?.(',')[1]; | ||
resolve(data); | ||
}; | ||
reader.onerror = reject; | ||
reader.readAsDataURL(file); | ||
}); | ||
} |