Skip to content

Commit a3f7e57

Browse files
committed
add file validation on drop
1 parent ff57556 commit a3f7e57

File tree

5 files changed

+51
-25
lines changed

5 files changed

+51
-25
lines changed

dist/filepond-plugin-file-validate-size.esm.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
/*
2-
* FilePondPluginFileValidateSize 1.0.1
2+
* FilePondPluginFileValidateSize 1.0.2
33
* Licensed under MIT, https://opensource.org/licenses/MIT
44
* Please visit https://pqina.nl/filepond for details.
55
*/
66
var plugin$1 = ({ addFilter, utils }) => {
77
// get quick reference to Type utils
88
const { Type, replaceInString, toNaturalFileSize } = utils;
99

10+
// filtering if an item is allowed in hopper
11+
addFilter('ALLOW_HOPPER_ITEM', (file, { query }) => {
12+
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) {
13+
return true;
14+
}
15+
16+
const sizeMax = query('GET_MAX_FILE_SIZE');
17+
if (sizeMax !== null && file.size > sizeMax) {
18+
return false;
19+
}
20+
return true;
21+
});
22+
1023
// called for each file that is loaded
1124
// right before it is set to the item state
1225
// should return a promise
@@ -15,8 +28,7 @@ var plugin$1 = ({ addFilter, utils }) => {
1528
(file, { query }) =>
1629
new Promise((resolve, reject) => {
1730
// if not allowed, all fine, exit
18-
const allowFileSizeValidation = query('GET_ALLOW_FILE_SIZE_VALIDATION');
19-
if (!allowFileSizeValidation) {
31+
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) {
2032
resolve(file);
2133
return;
2234
}

dist/filepond-plugin-file-validate-size.esm.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/filepond-plugin-file-validate-size.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* FilePondPluginFileValidateSize 1.0.1
2+
* FilePondPluginFileValidateSize 1.0.2
33
* Licensed under MIT, https://opensource.org/licenses/MIT
44
* Please visit https://pqina.nl/filepond for details.
55
*/
@@ -21,16 +21,30 @@
2121
replaceInString = utils.replaceInString,
2222
toNaturalFileSize = utils.toNaturalFileSize;
2323

24+
// filtering if an item is allowed in hopper
25+
26+
addFilter('ALLOW_HOPPER_ITEM', function(file, _ref2) {
27+
var query = _ref2.query;
28+
29+
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) {
30+
return true;
31+
}
32+
33+
var sizeMax = query('GET_MAX_FILE_SIZE');
34+
if (sizeMax !== null && file.size > sizeMax) {
35+
return false;
36+
}
37+
return true;
38+
});
39+
2440
// called for each file that is loaded
2541
// right before it is set to the item state
2642
// should return a promise
27-
28-
addFilter('LOAD_FILE', function(file, _ref2) {
29-
var query = _ref2.query;
43+
addFilter('LOAD_FILE', function(file, _ref3) {
44+
var query = _ref3.query;
3045
return new Promise(function(resolve, reject) {
3146
// if not allowed, all fine, exit
32-
var allowFileSizeValidation = query('GET_ALLOW_FILE_SIZE_VALIDATION');
33-
if (!allowFileSizeValidation) {
47+
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) {
3448
resolve(file);
3549
return;
3650
}

dist/filepond-plugin-file-validate-size.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"name": "filepond-plugin-file-validate-size",
3-
"version": "1.0.1",
4-
"description": "File Size Validation Plugin for FilePond",
5-
"homepage": "https://pqina.nl/filepond",
6-
"main": "dist/filepond-plugin-file-validate-size.js",
7-
"browser": "dist/filepond-plugin-file-validate-size.js",
8-
"module": "dist/filepond-plugin-file-validate-size.esm.js",
9-
"license": "MIT",
10-
"author": {
11-
"name": "PQINA",
12-
"url": "https://pqina.nl"
13-
}
2+
"name": "filepond-plugin-file-validate-size",
3+
"version": "1.0.2",
4+
"description": "File Size Validation Plugin for FilePond",
5+
"homepage": "https://pqina.nl/filepond",
6+
"main": "dist/filepond-plugin-file-validate-size.js",
7+
"browser": "dist/filepond-plugin-file-validate-size.js",
8+
"module": "dist/filepond-plugin-file-validate-size.esm.js",
9+
"license": "MIT",
10+
"author": {
11+
"name": "PQINA",
12+
"url": "https://pqina.nl"
13+
}
1414
}

0 commit comments

Comments
 (0)