Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fileReader.onload = () => {
const arrayBuffer = fileReader.result;
const uint8Array = new Uint8Array(arrayBuffer);
if (isPNG(uint8Array)) {
const metadata = readMetadataSync(uint8Array);
const formatVersion = metadata["Mopaint Format Version"];
if (formatVersion) {
const json = metadata["Program Source"];
this.loadDocumentFromJSON(json);
} else {
// TODO: handle plain image files
this.showError({
message:
"Loading images is not supported yet (other than Mopaint PNG programs)",
});
}
} else if (uint8Array[0] === "{".charCodeAt(0)) {
const fileReader = new FileReader();
fileReader.onload = () => {
this.loadDocumentFromJSON(fileReader.result);