Commit ccf7dc631823614c00d6071b78707164c91106cb
Committed by
Michel Felipe

1 parent
07858dff
Exists in
master
and in
6 other branches
Added upload image to person service
Showing
1 changed file
with
15 additions
and
0 deletions
Show diff stats
src/lib/ng-noosfero-api/http/person.service.ts
... | ... | @@ -28,4 +28,19 @@ export class PersonService extends RestangularService<noosfero.Person> { |
28 | 28 | p.catch(this.getHandleErrorFunction<noosfero.RestResult<any>>(deferred)); |
29 | 29 | return deferred.promise; |
30 | 30 | } |
31 | + | |
32 | + uploadImage(profile: noosfero.Profile, base64_image_json: any) { | |
33 | + let headers = { 'Content-Type': 'application/json' }; | |
34 | + let deferred = this.$q.defer<noosfero.RestResult<noosfero.Profile>>(); | |
35 | + // TODO dynamically copy the selected attributes to update | |
36 | + let attributesToUpdate: any = { | |
37 | + person: { image_builder: base64_image_json } | |
38 | + }; | |
39 | + let restRequest: ng.IPromise<noosfero.RestResult<any>> = | |
40 | + this.getElement(profile.id).customPOST(attributesToUpdate, null, null, headers); | |
41 | + restRequest.then(this.getHandleSuccessFunction(deferred)) | |
42 | + .catch(this.getHandleErrorFunction(deferred)); | |
43 | + return deferred.promise; | |
44 | + } | |
45 | + | |
31 | 46 | } | ... | ... |