-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IE8 does not use the headers supplied in upload config #111
Comments
Looks like this may be a limitation of the FileAPI flash shim:
In which case I'm not sure there's much to be done, except perhaps document this limitation. I'll wait for responses here, but will work on a server-side workaround in the meantime. |
Thanks for figuring this out. |
Seems like that's just an error in the FileAPI docs and flash should support custom headers. |
I'm not 100% on FileAPI being the actual limitation here, but I do know that setting arbitrary headers works on modern browsers but not IE8 with the shims in place. Could there be a config issue on my end? |
Do you use CORS? |
No CORS. It looks like there's another comment on that issue you opened that might explain it - points to http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html#upload() |
Finally found the new location of the "link-to-comment" feature in github! Here's the comment I was referring to: https://github.com/mailru/FileAPI/issues/189#issuecomment-33559283 |
Headers are supported in FileAPI, my file upload works when I call (My request header must contain a csrf token) |
FileAPI doesn't support custom headers for Flash (IE8-9) |
Hi Danial, Let me sum it up to make things clearer : So, my questions are :
|
You are right.
|
Thanks for the quick and thorough reply. We'll weigh our options in the light of those informations. We are considering creating a fork of the FileAPI project, as we have talented flash devs in our company and this seems the better option. Be sure that if we end up making an alternative version of the FileAPI project, we'll either propose a PR or make the fork publicly available. |
After a bit of digging with our flash devs, it seems we are indeed stuck on the FileAPI side. By design, Adobe prevents the use of custom headers when using FileReference.upload().
We're gonna dig a bit more into it, but the most probable scenario is that anything coming from a FileReference (i.e. access to user file system) will only be sendable through FileReference.upload(), so without any way to tweak the headers. Another issue related to the header tweaking is that the "Accept" header sent by the FileReference.upload() method has a "text/*" value ( cf #121 ). If your server is only sending "application/json" as a result, it may deny the request. If the "no tweak in headers" rule sticks, that means this problem can only be handled serverside. For now, we've decided to passed the authorization token through the url query and let the server return text/json if the request is text/*. text/json is not the official content-type, but it's a quite common one anyhow so we don't expect it to raise any problem. With this setup, we're now able to send a file to the server. It works alright in IE9, we're still trying to figure out why the upload doesn't start in IE8 -> #281 |
If you specify headers in the upload config object, like this:
...they are used by modern browsers. But IE8 with the flash shim always sends the same request headers regardless - it appears to be hard-coded, though I haven't dug into that yet.
In my particular case, the 'Accept: text/*' that IE8 uses in requests is causing my server to throw 406 errors because the response is configured to return the "application/json" content-type.
Thanks for the very useful module and please let me know if there's something I can do to help troubleshoot!
The text was updated successfully, but these errors were encountered: