leon / angular-upload

Upload service with iframe fallback and some nice directives to go with it.
MIT License
234 stars 100 forks source link

Obsolete code since for angular 1.3+ #56

Open vitvad opened 8 years ago

vitvad commented 8 years ago

Hi recently migrate angular framework in my project from 1.2.28 to 1.4.7 And found that since this commit https://github.com/angular/angular.js/commit/7b6c1d08aceba6704a40302f373400aed9ed0e0b#diff-748e0a1e1a7db3458d5f95d59d7e16c9

angular changed their default response interceptor, now they require headers link

in upload code when you use force Iframe option, https://github.com/leon/angular-upload/blob/master/angular-upload.js#L254 iframe doesn't has headers for you try to call interceptor with Array instead of function.

angular defaultHttpResponseTransform fall with Uncaught TypeError: headers is not a function(…) and as soon as in upload you call all transformation in try{}catch(){} https://github.com/leon/angular-upload/blob/master/angular-upload.js#L215 you will never see this error, but you also never get proper JSON response from angular interceptor.

suggested fix: change https://github.com/leon/angular-upload/blob/master/angular-upload.js#L252 to

var headers = function(){}; // not sure is there any sense return anything for iframe 

P.S. up to you if you want change anything. I guess people who use you library parse json response manually