-
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
FormData should not be passed to $http config as data #504
Comments
There is a difference between the If you want to modify the property names at the root level of |
Hi Danial, congratulation for the great job you've been doing with angular-file-upload! Maybe I've failed to explain myself, but passing it as an object or as field names is indifferent to who is passing the object, but for the chain of interceptors it is way different, and both ways are subject to the encoding phase that will get the data passed and serialize it to be transmitted and then used by the server-side. The thing is that angular-file-upload internally passes a FormData instance to $http and it becomes impossible to modify or even read its properties before the request is made except for the This will allow interceptors to work with that data object as a common object and when the time is right we convert it to a FormData instance along with the file and encode it in a way $http is able to make the correct request. Does it make sense? |
I see what you mean now. Yea I think your approach is cleaner. |
Version 3.0.0 will not touch the |
👍 congratulations and thanks for fixing it so quickly ;) |
Method
append
undefined on the FormData instance passed to theformDataAppender
function.Steps to reproduce:
1 - Install angular-http-case-converter
2 - Install angular-upload-file
3 - Configure an input file as the rails example (with the formDataAppender function)
4 - Run the application and try to upload something
angular-upload-file version: 2.1.1
angular: 1.3.3
angular-http-case-converter: 0.1.1
Long explanation:
I'm using angular-http-case-converter to normalize formats between JavaScript (camelCase) and Ruby (snake-case), so during the transformation process it creates a new object transfering the properties of the original object to the new one while converting their format.
The problem is that the object being passed when I use angular-file-upload is FormData and this process replaces the original object making an error occur when the request transformer calls the
append
method that doesn't exist on the new object created by the interceptor that converted the format.The text was updated successfully, but these errors were encountered: