danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flash FileAPI HTTP error code 400 is treated as success

gessnerfl opened this issue · comments

Hi,

I need the flash-based FileApi solution for IE8 support. Thereby I face the following issue:
I try to bind event handler for all three events (success, error, progress). In the HTML5 version without FileApi everything works fine. But with the FileAPI the success handler is called in case of an error but in case of an successful upload no handler is called.

This issue happens when using success( ), error( ), and progress( ) and also when just using then( ) to bind the event handler functions.

I am using the latest version 1.2.3.

Thanks and Best Regards
Florian

What version of angularjs?

I am using angular 1.0.3.

you mean 1.2.3?
Only angular 1.0.7+ is supported by this plugin.

I updated to the latest version of angular (1.2.6) but I still face exactly the same issue

Try the demo page. It uses the then() function and it does receive the success result to show on the page.
See if he demo page works on your IE8.

The demo page works fine but it is not really representative in this case because there is not error handler in place.
I made some detailed analysis and figured out what is going wrong:

  • My implementation did not return any data when upload was successful but just confirmed the upload with HTTP Code 200.
  • I added some dummy data and after this the handler is being triggered.

HOWEVER

  • When an error occurs the backend response with HTTP Code 400 and additional details in the data segment
  • In IE also the success handler will be triggered and status code is not 400 but 200.
  • If I would not return any data in the 400 response no error handler will be triggered at all.

I used fiddler2 to get the original HTTP traffic and used the IE8 developer tools for debugging.

Are there any limitations in respect to the File API?

Seems like a bug with Flash or FileAPI.
If server returns an error code > 400 it would work but only 400 will be considered as 200 success in FileAPI.
So the workaround would be to return any other error code like 403, 500 and you would be able to get error callback.
Thanks for investigating this. I have already asked the question in the FileAPI issue tracker I will update you if I know more about this issue.

Doesn't seem to be that serious issue since there are workarounds and not an easy solution since it is a flash FileAPI related issue. Marking it as won't fix for now.