remove rocket chat

This commit is contained in:
Peter Maquiran
2024-08-09 10:50:32 +01:00
parent 45e829bec3
commit 6cbd8d903c
67 changed files with 962 additions and 5618 deletions
+30
View File
@@ -0,0 +1,30 @@
import { err, ok, Result } from "neverthrow";
/**
* Retrieves a `FileReader` instance, accounting for potential Zone.js modifications.
* @returns {FileReader} The original `FileReader` instance or a modified one if applicable.
*/
function getFileReader(): FileReader {
const fileReader = new FileReader();
const zoneOriginalInstance = (fileReader as any)["__zone_symbol__originalInstance"];
return zoneOriginalInstance || fileReader;
}
/**
* Converts a `File` object to a Base64 encoded string.
* @param {File} file - The file to be converted.
* @returns {Promise<Result<string, any>>} A promise that resolves with a `Result` object containing either the Base64 encoded string or an error.
*/
export function JSFileToBase64(file: File): Promise<Result<string, any>> {
return new Promise((resolve, reject) => {
var reader = getFileReader();
reader.readAsDataURL(file);
reader.onload = function () {
resolve(ok(reader.result as string));
};
reader.onerror = function (error) {
console.log('Error: ', error);
resolve(err(error));
};
});
}