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

Closed
montgomery1944 opened this Issue May 30, 2015 · 2 comments

Projects

None yet

2 participants

@montgomery1944

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 danialfarid pushed a commit that referenced this issue Jun 4, 2015
Danial Farid Fixed #783 #764 #777 #766 #763 #761 #721 #687 #650 #710 #784 #768 #789 39fa784
@danialfarid
Owner

Fixed in version 5.0.0,

@danialfarid
Owner

Added option sendFieldsAs: 'json-blob'

@danialfarid danialfarid closed this Jun 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment