aboutsummaryrefslogtreecommitdiff
path: root/src/hooks
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-08-22 01:22:51 +0300
committereug-vs <eug-vs@keemail.me>2020-08-22 01:22:51 +0300
commit697279f7fd5d6571a3a7599fb51ba57af2aa8945 (patch)
treef85f069b4d5e9caa9179d00accd1b5be4db37bf5 /src/hooks
parent611d90f557140c442e4066e396d8c12ce4c340d3 (diff)
downloadwhich-ui-697279f7fd5d6571a3a7599fb51ba57af2aa8945.tar.gz
refactor: move compressFile to utils
Diffstat (limited to 'src/hooks')
-rw-r--r--src/hooks/useS3Preupload.tsx14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/hooks/useS3Preupload.tsx b/src/hooks/useS3Preupload.tsx
index 651bfb6..9516459 100644
--- a/src/hooks/useS3Preupload.tsx
+++ b/src/hooks/useS3Preupload.tsx
@@ -1,9 +1,8 @@
import { useState, useCallback, useMemo } from 'react';
import axios from 'axios';
import Bluebird from 'bluebird';
-import Compressor from 'compressorjs';
import { get } from '../requests';
-
+import { compressFile } from '../utils/files';
interface ProgressEvent {
loaded: number;
@@ -17,17 +16,6 @@ interface Hook {
progress: number;
}
-
-const compressFile = (file: File, quality = 0.6): Promise<Blob> => {
- return new Promise((resolve, reject) => {
- return new Compressor(file, {
- success: result => resolve(result),
- error: err => reject(err),
- quality
- });
- });
-};
-
export default (): Hook => {
const [url, setUrl] = useState<string>();
const [file, setFile] = useState<File>();