Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (const file of Array.from(files)) {
let error = '';
// Max file size
if ((file.size / 1024 / 1024 /*in MB*/) > this.maxFileSizeInMB) {
error = `File exceeds ${this.maxFileSizeInMB} MB. Please upload a smaller file`;
return;
}
try {
const compressedFile = await this.compress(file);
const metadata = await this.preview(compressedFile);
// https://stackoverflow.com/a/32490603/10395024
// https://i.stack.imgur.com/VGsAj.gif
const exifOrientation = await imageCompression.getExifOrientation(file);
this.previewImages.push({
file: compressedFile,
...metadata,
exifOrientation,
errorMessage: error
});
this.changed.emit();
} catch (error) {
// TODO: error handling
}
}
}