2

I'm lost trying to upload a file using restangular.js as part of a multi-part form.

This is the error I get:

XPCWrappedNative_NoHelper { message: "JavaScript component does not have a method named: "available"'JavaScript component does not have a method named: "available"' when calling method: [nsIInputStream::available]", result: 2153185328, name: "NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED", filename: "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.js", lineNumber: 8407, columnNumber: 0, location: XPCWrappedNative_NoHelper, inner: null, data: null } angular.js:9899
XPCWrappedNative_NoHelper { message: "JavaScript component does not have a method named: "available"'JavaScript component does not have a method named: "available"' when calling method: [nsIInputStream::available]", result: 2153185328, name: "NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED", filename: "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.js", lineNumber: 8407, columnNumber: 0, location: XPCWrappedNative_NoHelper, inner: null, data: null }

This is my code to send the object:

$rootScope.objects.user.withHttpConfig({
    transformRequest: angular.identity
    },
}).customPUT($scope.objects.user, "", { // I've tried regular `put` as well
    'Content-Type': undefined
}).then(function(resp) {
    if (resp == "OK") {
        $scope.successes = [{
            msg: "Saved"
        }];
    }
}, function(err) {
    console.log(err);
    $scope.errors = err.data.errors;
});

The user object contains the following:

{
   username: "...",
   email: "...",
   profilePicture: [File] // What makes this complicated
}
sinθ
  • 11,093
  • 25
  • 85
  • 121
  • Why PUT and not POST ? – originof Jun 30 '14 at 19:53
  • possible duplicate of [Firefox exception 'JavaScript component does not have a method named: "available"'](http://stackoverflow.com/questions/15772920/firefox-exception-javascript-component-does-not-have-a-method-named-available) – originof Jun 30 '14 at 19:56
  • @originof I'm updating a user's settings, not creating a new user. – sinθ Jun 30 '14 at 21:27
  • @originof Thanks for the link. I already checked that out and, when I tried `JSON.stringify` on everything BUT the file object, I still got the same error. – sinθ Jun 30 '14 at 21:28
  • Is that your code exactly? Because you have a problem with line 3, namely `},` shouldn't be there at all. – kiswa Jul 30 '14 at 19:43
  • @kiswa No, that isn't (wasn't) in my code. I ended up just using native Javascript to get it to work. – sinθ Jul 30 '14 at 23:11

0 Answers0