File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ import { Injectable } from '@angular/core';
22import { Platform } from 'ionic-angular' ;
33import { ImagePicker } from '@ionic-native/image-picker' ;
44import { UploadFS } from 'meteor/jalik:ufs' ;
5+ import { PicturesStore } from 'api/collections' ;
6+ import * as _ from 'lodash' ;
7+ import { DEFAULT_PICTURE_URL } from 'api/models' ;
58
69@Injectable ( )
710export class PictureService {
@@ -29,7 +32,23 @@ export class PictureService {
2932 }
3033
3134 upload ( blob : File ) : Promise < any > {
32- return Promise . resolve ( ) ;
35+ return new Promise ( ( resolve , reject ) => {
36+ const metadata : any = _ . pick ( blob , 'name' , 'type' , 'size' ) ;
37+
38+ if ( ! metadata . name ) {
39+ metadata . name = DEFAULT_PICTURE_URL ;
40+ }
41+
42+ const upload = new UploadFS . Uploader ( {
43+ data : blob ,
44+ file : metadata ,
45+ store : PicturesStore ,
46+ onComplete : resolve ,
47+ onError : reject
48+ } ) ;
49+
50+ upload . start ( ) ;
51+ } ) ;
3352 }
3453
3554 convertURLtoBlob ( url : string , options = { } ) : Promise < File > {
You can’t perform that action at this time.
0 commit comments