0

I am using angular-file-upload directive for uploading a file in my application. And also I want to send some form data in JSON format along with the file. Using this configuration for uploading.

Upload.upload({
    url: "https://angular-file-upload-cors-srv.appspot.com/upload",
    fields: $scope.conf,
    sendObjectsAsJsonBlob: true,
    file: $scope.conf.file
});

But the problem is the values that are passed along with the file are in format

Headers:

[{fieldName: "accessKeyId", value: "1111"},
{fieldName: "accessKey", value: "aaaa"}]

And I want it in form of:

{"accessKeyId": "1111", "accessKey": "aaaa"} 

Please tell me the configuration I required to pass for this format.

4
  • you have to show more code, could you create a jsfiddle or plnkr or something? Commented May 18, 2015 at 4:50
  • I don't see Headers in your code for upload? Commented May 18, 2015 at 6:28
  • @Pindakaas: please refer angular-file-upload directive - github.com/danialfarid/ng-file-upload Commented May 18, 2015 at 6:35
  • @HuyHoangPham: please refer angular-file-upload directive - github.com/danialfarid/ng-file-upload Commented May 18, 2015 at 6:36

1 Answer 1

1

please use

var data = angular.fromJson($scope.yourvariable);

and pass this variable in ajax call

Sign up to request clarification or add additional context in comments.

4 Comments

Can you please specify where exactly in my function i have to place this function?
can you please tell me variable name of following value [{fieldName: "accessKeyId", value: "1111"} {fieldName: "accessKey", value: "aaaa"}]
It is passed inside result: [..]. You can refer jsfiddle.net/3t50b3fw this link for an example.
i can not understand what you want but in general if you want to pass object after convert into json .you can pass object in angular.fromJson.............object will convert into json format.let me know how you go

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.