mercredi 30 décembre 2015

Angular JS file upload with JSON

Im using the package below:

http://ift.tt/1B2mEGK

I can touch my file, but im running on the fact that my console.log gives back a blob. How can i transform that to an image? My console.log is here below:

File {$ngfBlobUrl: "blob:http%3A//http://ift.tt/22ziisg", $ngfWidth: 1200, $ngfHeight: 1600}
  $ngfBlobUrl: "blob:http%3A//http://ift.tt/22ziisg"
  $ngfHeight: 1600
  $ngfWidth: 1200
  lastModified: 1451421983000
  lastModifiedDate: Tue Dec 29 2015 21:46:23 GMT+0100 (CET)
  name: "20151229124600.jpg"
  size: 414563
  type: "image/jpeg"
  webkitRelativePath: ""
  __proto__: File

Currently i only have this in my EventController:

$scope.setFlyer = function ( part )
{
    console.log($scope.flyers.front);
    console.log($scope.flyers.front.$ngfBlobUrl);


    $scope.flyers[part] = {
        blob: $scope.flyers[part].$ngfBlobUrl
    };

};

$scope.updateEvent = function ()
{
    eventFactory.setEvent($scope.event.event, $scope.organisationID, $scope.flyers)
        .then(function ( response )
        {
            if ( response.data.status == 'success' )
            {
                eventFactory.getEvents(1, $scope.organisationID)
                    .then(function ( response )
                    {
                        $scope.events = response.data.events;
                        $scope.event = [];
                        $scope.event.club = [];
                        $scope.event.organisation = [];
                    });
            }
        });
};

My eventDirective:

setEvent: function ( data, organisationID, flyerSet )
    {
        var json = JSON.stringify({
            json: data,
            organisation_id: organisationID,
            flyers: flyerSet
        });

        return $http.post('/api/v1/event/update', json);
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire