@@ -2,12 +2,11 @@ Template.afFileUpload.onCreated(function () {
22 this . collectionName = ( ) => this . data . atts . collection
33 this . fileId = new ReactiveVar ( this . data . value ) ;
44 this . currentUpload = new ReactiveVar ( false ) ;
5+ return ;
56} ) ;
67
7-
8-
98Template . afFileUpload . helpers ( {
10- currentUpload : function ( ) {
9+ currentUpload ( ) {
1110 return Template . instance ( ) . currentUpload . get ( ) ;
1211 } ,
1312 fileId ( ) {
@@ -23,29 +22,27 @@ Template.afFileUpload.helpers({
2322Template . afFileUpload . events ( {
2423 'click [data-action="remove-file"]' ( e , t ) {
2524 t . fileId . set ( false ) ;
25+ return ;
2626 } ,
27- 'change .af-file-upload-capture' : function ( e , template ) {
27+ 'change .af-file-upload-capture' ( e , template ) {
2828 if ( e . currentTarget . files && e . currentTarget . files [ 0 ] ) {
29- // We upload only one file, in case
30- // multiple files were selected
31- var upload = global [ template . collectionName ( ) ] . insert ( {
29+ const upload = global [ template . collectionName ( ) ] . insert ( {
3230 file : e . currentTarget . files [ 0 ] ,
3331 streams : 'dynamic' ,
3432 chunkSize : 'dynamic'
3533 } , false ) ;
3634
3735 upload . on ( 'start' , function ( ) {
3836 template . currentUpload . set ( this ) ;
37+ return ;
3938 } ) ;
4039
41- upload . on ( 'end' , function ( error , fileObj ) {
42- if ( error ) {
43- //alert('Error during upload: ' + error);
44- } else {
45- //alert('File "' + fileObj.name + '" successfully uploaded');
40+ upload . on ( 'end' , ( error , fileObj ) => {
41+ if ( ! error ) {
4642 template . fileId . set ( fileObj . _id ) ;
4743 }
4844 template . currentUpload . set ( false ) ;
45+ return ;
4946 } ) ;
5047
5148 upload . start ( ) ;
0 commit comments