Last active
July 22, 2018 13:37
-
-
Save bverbeken/8282925 to your computer and use it in GitHub Desktop.
Revisions
-
bverbeken revised this gist
Jan 6, 2014 . 2 changed files with 34 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ $scope.saveMyObject = function () { method: 'POST', url: '/my/url', headers: { 'Content-Type': undefined // --> makes sure the boundary is set in the Content-Type header, see result file }, data: { file: $scope.file, This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ Request Headers =============== POST /my/url HTTP/1.1 Host: localhost:8083 Connection: keep-alive Content-Length: 355 Authorization: Basic ZDpk Accept: application/json, text/plain, */* Origin: http://localhost:8083 X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryPcJBO0iJ6WlKSynv Referer: http://localhost:8083/ Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8,fr;q=0.6 Request Payload =============== ------WebKitFormBoundaryPcJBO0iJ6WlKSynv Content-Disposition: form-data; name="file" somefile.txt ------WebKitFormBoundaryPcJBO0iJ6WlKSynv Content-Disposition: form-data; name="startDate" 2014-01-09 ------WebKitFormBoundaryPcJBO0iJ6WlKSynv Content-Disposition: form-data; name="endDate" 2014-01-30 ------WebKitFormBoundaryPcJBO0iJ6WlKSynv-- -
bverbeken created this gist
Jan 6, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ $scope.saveMyObject = function () { return $http({ method: 'POST', url: '/my/url', headers: { 'Content-Type': undefined }, data: { file: $scope.file, startDate: $scope.startDate, endDate: $scope.endDate }, transformRequest: function(data) { var fd = new FormData(); angular.forEach(data, function(value, key) { fd.append(key, value); }); return fd; } }); }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ ... @RequestMapping(method = POST, consumes = "multipart/form-data") public void submit(@RequestBody MultiValueMap<String, Object> requestBody) { // do stuff }