angular-file-upload icon indicating copy to clipboard operation
angular-file-upload copied to clipboard

Using angular interceptors in uploader request

Open mort3za opened this issue 10 years ago • 12 comments

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.

mort3za avatar Jun 14 '15 13:06 mort3za

Current version is not support this.

nervgh avatar Jun 23 '15 17:06 nervgh

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.

aosi87 avatar Jul 07 '15 23:07 aosi87

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!

bitbay avatar Oct 12 '15 10:10 bitbay

+1 ! It would be really great to be able to use interceptors.

chris-verclytte avatar Oct 27 '15 10:10 chris-verclytte

+1

nick-allen avatar May 18 '16 02:05 nick-allen

+1

Aetherus avatar Oct 11 '16 06:10 Aetherus

+1

felixbillon avatar Oct 13 '16 09:10 felixbillon

+1

thmarti avatar Feb 09 '17 10:02 thmarti

+1

bnbarak avatar Feb 28 '17 22:02 bnbarak

+1

lannotimo avatar Mar 31 '17 06:03 lannotimo

+1

mrgoos avatar Jun 04 '17 15:06 mrgoos

It can help you...at moment, alright? capturar

souzara avatar Oct 05 '17 12:10 souzara