Skip to content

Commit

Permalink
FEATURE: Returning falsy value from upload handler stops upload. (#6969)
Browse files Browse the repository at this point in the history
  • Loading branch information
udan11 authored and ZogStriP committed Feb 5, 2019
1 parent a342d2f commit 2c222e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -681,8 +681,9 @@ export default Ember.Component.extend({

const matchingHandler = uploadHandlers.find(matcher);
if (data.files.length === 1 && matchingHandler) {
matchingHandler.method(data.files[0]);
return false;
if (!matchingHandler.method(data.files[0])) {
return false;
}
}

// If no plugin, continue as normal
Expand Down
3 changes: 2 additions & 1 deletion app/assets/javascripts/discourse/lib/plugin-api.js.es6
Expand Up @@ -786,7 +786,8 @@ class PluginApi {
/**
*
* Registers a function to handle uploads for specified file types
* The normal uploading functionality will be bypassed
* The normal uploading functionality will be bypassed if function returns
* a falsy value.
* This only for uploads of individual files
*
* Example:
Expand Down

0 comments on commit 2c222e1

Please sign in to comment.