Webuploader Event Description
uploadBeforeSend |
object {Object}
data {Object}The default upload parameters, which can be extended to control the upload parameters.
headers {Object}You can extend this object to control the upload header.
|
When a chunk of a file is triggered before it is sent, it is used primarily to ask whether to add an accompanying parameter, and this event may be triggered multiple times when a large file is opened with a multipart upload. |
"Webuploader API documentation "
Add an interceptor to the ANGULARJS, for example:
//Add a Submit tokenSxapp.factory (' Sessioninjector ',function($rootScope, locals) {//Service Logic$rootscope.sysuser.token varSessioninjector ={request:function(config) { config.headers.token = Locals.getobject ("Accesstoken"); if(config.method== "POST"){ ... ... } returnconfig; } }; returnsessioninjector;});
Here the headers.token to Webuploader plug-ins do not work, then you need to configure the header in Webuploader, find the webuploader.js in the Uploadbeforesend method, in the header defined in the upload operation method _dosend , add headers.token = Globalconfig.token; This line of code
/** * @event Uploadbeforesend * @param {Object} Object * @param {object} data default upload parameter , you can extend this object to control the upload parameters. * @param {Object} headers can extend this object to control the upload header. * @description when a chunk of a file is triggered before it is sent, it is primarily used to ask if it is possible to add an accompanying parameter, and this event may trigger multiple times when a large file is opened with a multipart upload. * @for Uploader*/ //do the upload operation. _dosend:function(block) {varme = This, owner=Me.owner, opts=me.options, File=Block.file, tr=NewTransport (opts), data=$.extend ({}, Opts.formdata), headers=$.extend ({}, opts.headers), requestaccept, ret; Headers.token = Globalconfig.token; Block.transport=TR; Tr.on (' Destroy ',function() { DeleteBlock.transport; Me._popblock (block); Base.nexttick (Me.__tick); });
Note: Since Angularjs and jquery are cumbersome to pass values, a global variable globalconfig.tokenis declared here, passing values between Angularjs and jquery.
Declare a global variable in config.js:
function GlobalConfig () {}globalconfig.token= "";(function() {}) ();
To pass the value in App.js:
Globalconfig.token = Locals.getobject ("Accesstoken");
About Headers.token interception issues with Webuploader upload file plugin