|
18 | 18 |
|
19 | 19 | **react-native-compressor** package is a set of functions that allow you compress `Image`,`Audio` and `Video` |
20 | 20 |
|
| 21 | +If you find this package useful hit the star 🌟 |
| 22 | + |
21 | 23 | ## Installation |
22 | 24 |
|
23 | 25 | #### For React Native 0.64 or lower |
@@ -150,6 +152,23 @@ const result = await Audio.compress( |
150 | 152 | ); |
151 | 153 | ``` |
152 | 154 |
|
| 155 | +### Background Upload |
| 156 | + |
| 157 | +```js |
| 158 | +import { backgroundUpload } from 'react-native-compressor'; |
| 159 | + |
| 160 | +const headers = {}; |
| 161 | + |
| 162 | +const uploadResult = await backgroundUpload( |
| 163 | + url, |
| 164 | + fileUrl, |
| 165 | + { httpMethod: 'PUT', headers }, |
| 166 | + (written, total) => { |
| 167 | + console.log(written, total); |
| 168 | + } |
| 169 | +); |
| 170 | +``` |
| 171 | + |
153 | 172 | # API |
154 | 173 |
|
155 | 174 | ## Image |
@@ -217,6 +236,30 @@ const result = await Audio.compress( |
217 | 236 |
|
218 | 237 | **Note: Audio compression will be add soon** |
219 | 238 |
|
| 239 | +## Background Upload |
| 240 | + |
| 241 | +- ###### `backgroundUpload: (url: string, fileUrl: string, options: FileSystemUploadOptions, onProgress?: ((writtem: number, total: number) => void) | undefined) => Promise<any> |
| 242 | + |
| 243 | +- ###### ` FileSystemUploadOptions` |
| 244 | + |
| 245 | +```js |
| 246 | +type FileSystemUploadOptions = ( |
| 247 | + | { |
| 248 | + uploadType?: FileSystemUploadType.BINARY_CONTENT, |
| 249 | + } |
| 250 | + | { |
| 251 | + uploadType: FileSystemUploadType.MULTIPART, |
| 252 | + fieldName?: string, |
| 253 | + mimeType?: string, |
| 254 | + parameters?: Record<string, string>, |
| 255 | + } |
| 256 | +) & { |
| 257 | + headers?: Record<string, string>, |
| 258 | + httpMethod?: FileSystemAcceptedUploadHttpMethod, |
| 259 | + sessionType?: FileSystemSessionType, |
| 260 | +}; |
| 261 | +``` |
| 262 | + |
220 | 263 | ## Contributing |
221 | 264 |
|
222 | 265 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. |
|
0 commit comments