Skip to content
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

Usage of sendObjectsAsJsonBlob option leads to sending of invalid value to the server #777

Closed
montgomery1944 opened this issue May 30, 2015 · 3 comments

Comments

@montgomery1944
Copy link

When using sendObjectsAsJsonBlob option ng-file-upload uses "formData.append(key, new Blob([val], {type: 'application/json'}));" code to add object to the form data. The problem is, that browser before sending the data converts object to string, which in case of normal object leads to sending of "[object Object]" string to the server.

Right now to fix this issue I have to pass "new String(angular.toJson(object))" to the upload method to omit the "angular.isString(val)" condition, which is adding string without the "application/json" type. Then the serialization is calling toString() method on the String object, which is returning the proper JSON representation of the object.

I think that the library should call "formData.append(key, new Blob([JSON.stringify(val)], {type: 'application/json'}));" to fix this issue.

danialfarid pushed a commit that referenced this issue Jun 4, 2015
@danialfarid
Copy link
Owner

Fixed in version 5.0.0,

@danialfarid
Copy link
Owner

Added option sendFieldsAs: 'json-blob'

@Ashlandky
Copy link

I’m looking for someone to review my wife’s files I have them on phone but I have no clue what I’m looking at . 606-315-6602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants