{"action":"closed","issue":{"url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/816","labels_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/816/labels{/name}","comments_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/816/comments","events_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/816/events","html_url":"https://github.com/danialfarid/ng-file-upload/issues/816","id":88064456,"number":816,"title":"Base64 Encoding","user":{"login":"krusk","id":4613931,"avatar_url":"https://avatars.githubusercontent.com/u/4613931?v=3","gravatar_id":"","url":"https://api.github.com/users/krusk","html_url":"https://github.com/krusk","followers_url":"https://api.github.com/users/krusk/followers","following_url":"https://api.github.com/users/krusk/following{/other_user}","gists_url":"https://api.github.com/users/krusk/gists{/gist_id}","starred_url":"https://api.github.com/users/krusk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krusk/subscriptions","organizations_url":"https://api.github.com/users/krusk/orgs","repos_url":"https://api.github.com/users/krusk/repos","events_url":"https://api.github.com/users/krusk/events{/privacy}","received_events_url":"https://api.github.com/users/krusk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-06-13T20:53:53Z","updated_at":"2015-06-25T12:39:19Z","closed_at":"2015-06-25T12:39:19Z","body":"Hi all,\r\n\r\nI am attempting to use this directive to upload files into SharePoint, but it appears to be failing as the file needs to be Base64 encoded. How would I use this directive to encode via base64? My current code is as follows: (Note that the controller is bound at the page level)\r\n\r\nHTML:\r\n    \r\n    <div>\r\n                watching model:\r\n                <div class=\"button\" ngf-select ng-model=\"files\">Upload using model $watch</div>\r\n                <div class=\"button\" ngf-select ngf-change=\"upload($files)\">Upload on file change</div>\r\n                Image thumbnail: <img ngf-src=\"files[0]\" ngf-default-src=\"'/thumb.jpg'\" ngf-accept=\"'image/*'\">\r\n            </div>\r\n \r\nController:\r\n\r\n     appControllersUploadImage.controller('appUploadImageCtrl', ['$scope', '$location', 'Upload', function ($scope, $location, Upload) {\r\n        \r\n            $scope.$watch('files', function () {\r\n            $scope.upload($scope.files);\r\n        });\r\n\r\n        $scope.upload = function (files) {\r\n            if (files && files.length) {\r\n                for (var i = 0; i < files.length; i++) {\r\n                    var file = files[i];\r\n                    Upload.upload({\r\n                        url: \"/sites/ens/_api/web/lists/getByTitle('Images')/RootFolder/Files/add(url='test.jpg',overwrite='true')\",\r\n                        fields: {'Title': \"test\"},\r\n                        file: file,\r\n                        headers: {\r\n                            'Accept': 'application/json;odata=verbose', 'content-type': 'image/jpeg', 'X-RequestDigest': $(\"#__REQUESTDIGEST\").val()\r\n                        }\r\n                    }).progress(function (evt) {\r\n                        var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);\r\n                        console.log('progress: ' + progressPercentage + '% ' + evt.config.file.name);\r\n                    }).success(function (data, status, headers, config) {\r\n                        console.log('file ' + config.file.name + 'uploaded. Response: ' + data);\r\n                    });\r\n                }\r\n            }\r\n        };\r\n    }]);"}}