Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the beforeProcessFile hook #896

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/filepond.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.30.4
* FilePond 4.30.5
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down
17 changes: 14 additions & 3 deletions dist/filepond.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.30.4
* FilePond 4.30.5
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -603,7 +603,10 @@ const listeners = ({
};

viewExternalAPI.off = (type, fn) => {
events.splice(events.findIndex(event => event.type === type && event.fn === fn), 1);
events.splice(
events.findIndex(event => event.type === type && event.fn === fn),
1
);
remove(type, fn);
};

Expand Down Expand Up @@ -1959,6 +1962,7 @@ const defaultOptions = {
beforeAddFile: [null, Type.FUNCTION],
beforeRemoveFile: [null, Type.FUNCTION],
beforePrepareFile: [null, Type.FUNCTION],
beforeProcessFile: [null, Type.FUNCTION],

// styles
stylePanelLayout: [null, Type.STRING], // null 'integrated', 'compact', 'circle'
Expand Down Expand Up @@ -4834,7 +4838,14 @@ const actions = (dispatch, query, state) => ({
applyFilterChain('PREPARE_OUTPUT', file, { query, item })
.then(file => {
dispatch('DID_PREPARE_OUTPUT', { id: item.id, file });

// beforeProcessFile hook
const beforeProcess = query('GET_BEFORE_PROCESS_FILE');
if (beforeProcess && !beforeProcess(file)) {
let error = Error('beforeProcessFile hook prevented upload.');
item.abortProcessing();
failure({ error, item });
return;
}
success(file);
})
.catch(error);
Expand Down
4 changes: 2 additions & 2 deletions dist/filepond.esm.min.js

Large diffs are not rendered by default.

Loading