1717** REACT-NATIVE-COMPRESSOR** is a react-native package, which helps us to Compress ` Image ` , ` Video ` , and ` Audio ` before uploading, same like ** Whatsapp** without knowing the compression ` algorithm `
1818
1919<div align =" center " >
20- <img height = " 90 " src = " /media/whatsapp_logo.png " / >
21- & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;
22- <img height = " 90 " src = " /media/compress_media.png " / >
20+ <pre >
21+ < img height = " 90 " src = " /media/whatsapp_logo.png " /> < img height = " 90 " src = " /media/compress_media.png " />
22+ </ pre >
2323<h2 align =" center " >🗜️Compress Image, Video, and Audio same like Whatsapp</h2 >
2424</div >
2525
@@ -53,9 +53,7 @@ We should use **react-native-compressor** instead of **FFmpeg** because **react-
5353<summary >Open Table of Contents</summary >
5454
5555- [ Installation] ( #installation )
56- - [ For React Native] ( #react-native )
57- - [ For React Native<0.65] ( #for-react-native065 )
58- - [ For React Native 0.65 or greater] ( #for-react-native-065-or-greater )
56+ - [ For React Native] ( #Installation )
5957 - [ Managed Expo] ( #managed-expo )
6058- [ Usage] ( #usage )
6159 - [ Image] ( #image )
@@ -69,6 +67,7 @@ We should use **react-native-compressor** instead of **FFmpeg** because **react-
6967 - [ Video Api Docs] ( #video-1 )
7068 - [ Audio] ( #audio )
7169 - [ Background Upload] ( #background-upload )
70+ - [ Download File] ( #download )
7271
7372* [ Other Utilities] ( #api )
7473 - [ Background Upload] ( #background-upload-1 )
@@ -164,6 +163,7 @@ import { Image } from 'react-native-compressor';
164163const result = await Image .compress (' file://path_of_file/image.jpg' );
165164// OR
166165const result = await Image .compress (' https://path_of_file/image.jpg' , {
166+ progressDivider: 10 ,
167167 downloadProgress : (progress ) => {
168168 console .log (' downloadProgress: ' , progress);
169169 },
@@ -204,6 +204,7 @@ const result = await Video.compress(
204204const result = await Video .compress (
205205 ' https://example.com/video.mp4' ,
206206 {
207+ progressDivider: 10 ,
207208 downloadProgress : (progress ) => {
208209 console .log (' downloadProgress: ' , progress);
209210 },
@@ -288,6 +289,16 @@ const uploadResult = await backgroundUpload(
288289);
289290```
290291
292+ ### Download File
293+
294+ ``` js
295+ import { download } from ' react-native-compressor' ;
296+
297+ const downloadFileUrl = await download (url, (progress ) => {
298+ console .log (' downloadProgress: ' , progress);
299+ });
300+ ```
301+
291302# API
292303
293304## Image
@@ -308,6 +319,10 @@ const uploadResult = await backgroundUpload(
308319
309320 it is callback, only trigger when we pass image url from server
310321
322+ - ##### ` progressDivider?: number ` (default: 0)
323+
324+ we uses it when we use downloadProgress
325+
311326- ###### ` maxWidth: number ` (default: 1280)
312327
313328 The maximum width boundary used as the main boundary in resizing a landscape image.
@@ -348,6 +363,10 @@ const uploadResult = await backgroundUpload(
348363
349364 it is callback, only trigger when we pass image url from server
350365
366+ - ##### ` progressDivider?: number ` (default: 0)
367+
368+ we uses it when we use downloadProgress/onProgress
369+
351370- ###### ` maxSize: number ` (default: 640)
352371
353372 The maximum size can be height in case of portrait video or can be width in case of landscape video.
@@ -376,7 +395,7 @@ const uploadResult = await backgroundUpload(
376395
377396## Background Upload
378397
379- - ###### ` backgroundUpload: (url: string, fileUrl: string, options: FileSystemUploadOptions, onProgress?: ((writtem: number, total: number) => void) | undefined) => Promise<any >
398+ - ###### backgroundUpload: (url: string, fileUrl: string, options: FileSystemUploadOptions, onProgress?: ((writtem: number, total: number) => void) | undefined) => Promise< any >
380399
381400- ###### ` FileSystemUploadOptions `
382401
@@ -398,6 +417,10 @@ type FileSystemUploadOptions = (
398417};
399418```
400419
420+ ### Download
421+
422+ - ##### download: ( fileUrl: string, downloadProgress?: (progress: number) => void, progressDivider?: number ) => Promise< string >
423+
401424### Get Metadata Of Video
402425
403426if you want to get metadata of video than you can use this function
0 commit comments