angular-file-upload
angular-file-upload copied to clipboard
Using angular interceptors in uploader request
Is there a way to add custom interceptors to the uploader plugin requests? I added a interceptor to all my requests but it didn't apply on requests of this plugin. Any help will be appreciated.
Current version is not support this.
if you use ngResource when you create your $resource handler (angular factory) you can overwrite some methods, even so create functions inject queries if am not mistaken, you can use $q, $http callbacks to do what you want too, im a bit new on interceptors but thats the way im doing it right now. Cheers.
I have problems with dropzone exactly because of this - my interceptor (that check for "expired session" errors and automatically tries to refresh the session and repeats the previously failed request, in this case, the file upload) doesn't act on the upload fail because dropzone (being a jquery plugin) uses native browser XMLHttpRequest, just like angular-file-upload does. The solution would be using angulars $http service to do the uploading (and while we are at it, maybe mix-in promises).
The $http service is a core Angular service that facilitates communication with the remote HTTP servers via the browser's XMLHttpRequest object or via JSONP.
The $httpProvider.interceptors can only keep track of XMLHttpRequest instances wrapped by the $http service - hence while using new XMLHttpRequests (outside of angular) it won't be able to act on them.
I was wondering if uploading images through $http is technically impossible, or if this is just a major design flaw in this library...
Looks feature-full and promising though, thanks to all the contributors for Your hard work!
+1 ! It would be really great to be able to use interceptors.
+1
+1
+1
+1
+1
+1
+1
It can help you...at moment, alright?