angular-base64-upload icon indicating copy to clipboard operation
angular-base64-upload copied to clipboard

$http Upload

Open krusk opened this issue 9 years ago • 4 comments

Hi all, Using this directive, I can see how it outputs to base64, but am confused on how to pass this into my $http post as it is currently uploading a "corrupted" image file via SharePoint's REST API. HTML:

<form>
<input type="file" data-ng-model="files" base-sixty-four-input>
<button data-ng-click="upload()">Submit</button>
</form>

Upload Function:

$scope.upload = function () {
        console.log($scope.files);
                        $http.post("/sites/ens/_api/web/lists/getByTitle('Report Images')/RootFolder/Files/add(url='" + $scope.files.filename + "',overwrite='true')", $scope.files.base64,
                    {
                        headers: {
                            'X-RequestDigest': $("#__REQUESTDIGEST").val(),
                        }

                }).success(function (d) {
                    console.log(d);
                });
            }

krusk avatar Jun 15 '15 17:06 krusk

This is specific to SharePoint's REST API. I have no experience with it. Ask this question to other Sharepoint discussion group or Stackoverflow.

adonespitogo avatar Jun 16 '15 08:06 adonespitogo

Beyond SharePoint, are you passing $scope.files.base64 (assuming files is the name of the model). Or are you constructing a longer variable with data:image/type;base64,xxxxxxx

krusk avatar Jun 16 '15 11:06 krusk

console.log($scope.files); and you will see the data structure. It's up to you how to upload that to Sharepoint API.

adonespitogo avatar Jun 16 '15 13:06 adonespitogo

Thank you

krusk avatar Jun 16 '15 13:06 krusk