Skip to content

Commit 65bd6cc

Browse files
authored
Update example for file size validator (#78)
1 parent f067ac8 commit 65bd6cc

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# <center>Welcome to use-file-picker</center>
1+
# <center>Welcome to use-file-picker 👋</center>
22

33
## _Simple react hook to open browser file selector._
44

5-
[![alt Version](https://img.shields.io/npm/v/use-file-picker?color=blue)](https://www.npmjs.com/package/use-file-picker) [![alt License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#) [![alt Twitter: twitter.com/JankiewiczMi/](https://img.shields.io/twitter/follow/JankiewiczMi.svg?style=social)](https://twitter.com/twitter.com/JankiewiczMi)
5+
[![alt Version](https://img.shields.io/npm/v/use-file-picker?color=blue)](https://www.npmjs.com/package/use-file-picker) [![alt License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#) [![alt Twitter: twitter.com/jaaneek/](https://img.shields.io/twitter/follow/jaaneek.svg?style=social)](https://twitter.com/twitter.com/jaaneek)
66

7-
**🏠 [Homepage](https://github.com/Jaaneek/useFilePicker 'user-file-picker Github')**
7+
**🏠 [Homepage](https://github.com/Jaaneek/useFilePicker 'use-file-picker Github')**
88

99
## Documentation
1010

@@ -87,7 +87,7 @@ export default function App() {
8787
multiple: true,
8888
validators: [
8989
new FileAmountLimitValidator({ max: 1 }),
90-
new FileSizeValidator({ maxFileSize: 50 /* in megabytes */ }),
90+
new FileSizeValidator({ maxFileSize: 50 * 1024 * 1024 /* 50 MB */ }),
9191
new ImageDimensionsValidator({
9292
maxHeight: 900, // in pixels
9393
maxWidth: 1600,
@@ -349,17 +349,17 @@ const Imperative = () => {
349349
| -------------- | ---------------------------------------------------------------------------------------- |
350350
| openFilePicker | Opens file selector |
351351
| clear | Clears all files and errors |
352-
| filesContent | Get files array of type FileContent |
352+
| filesContent | Get files array of type FileContent |
353353
| plainFiles | Get array of the [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) objects |
354354
| loading | True if the reading files is in progress, otherwise False |
355-
| errors | Get errors array of type FileError if any appears |
355+
| errors | Get errors array of type FileError if any appears |
356356

357357
### Built-in validators
358358

359359
useFilePicker has some built-in validators that can be used out of the box. These are:
360360

361361
- FileAmountLimitValidator - allows to select a specific number of files (min and max) that will pass validation. This will work great with simple useFilePicker use cases, it will run on every file selection.
362-
- FileSizeValidator - allows to select files of a specific size (min and max) that will pass validation.
362+
- FileSizeValidator - allows to select files of a specific size (min and max) in bytes that will pass validation.
363363
- ImageDimensionsValidator - allows to select images of a specific size (min and max) that will pass validation.
364364
- PersistentFileAmountLimitValidator - allows to select a specific number of files (min and max) that will pass validation but it takes into consideration the previously selected files. This will work great with useImperativeFilePicker hook when you want to keep track of how many files are selected even when user is allowed to trigger selection multiple times before submitting the files.
365365

src/interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ export interface ImageDimensionRestrictionsConfig {
5555
}
5656

5757
export interface FileSizeRestrictions {
58-
/**Minimum file size in mb**/
58+
/**Minimum file size in bytes*/
5959
minFileSize?: number;
60-
/**Maximum file size in mb**/
60+
/**Maximum file size in bytes*/
6161
maxFileSize?: number;
6262
}
6363

0 commit comments

Comments
 (0)