feat: Compress avatar images before upload (#1751)

* compress avatar images before upload

* move compressImage to dedicated file

* Update ImageUpload.js
This commit is contained in:
Gustavo Maronato
2020-12-29 02:08:10 -03:00
committed by GitHub
parent b6ab816bb3
commit 89903b4bbe
4 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,17 @@
// @flow
import Compressor from "compressorjs";
type Options = Omit<Compressor.Options, "success" | "error">;
export const compressImage = async (
file: File | Blob,
options?: Options
): Promise<Blob> => {
return new Promise((resolve, reject) => {
new Compressor(file, {
...options,
success: resolve,
error: reject,
});
});
};