@@ -16,7 +16,12 @@ class StorageRef extends ReferenceBase {
16
16
17
17
downloadUrl ( ) : Promise < Object > {
18
18
const path = this . pathToString ( ) ;
19
- return promisify ( 'downloadUrl' , FirestackStorage ) ( this . storage . storageUrl , path ) ;
19
+ this . log . debug ( 'downloadUrl(' , path , ')' ) ;
20
+ return promisify ( 'downloadUrl' , FirestackStorage ) ( this . storage . storageUrl , path )
21
+ . catch ( err => {
22
+ this . log . error ( 'Error downloading URL for ' , path , '. Error: ' , err ) ;
23
+ throw err ;
24
+ } ) ;
20
25
}
21
26
22
27
/**
@@ -36,15 +41,17 @@ class StorageRef extends ReferenceBase {
36
41
listeners . push ( this . storage . _addListener ( 'download_resumed' , callback ) ) ;
37
42
38
43
const path = this . pathToString ( ) ;
44
+ this . log . debug ( 'download(' , path , ') -> ' , downloadPath ) ;
39
45
return promisify ( 'downloadFile' , FirestackStorage ) ( this . storage . storageUrl , path , downloadPath )
40
46
. then ( ( res ) => {
41
- console . log ( 'res --->' , res ) ;
47
+ this . log . debug ( 'res --->' , res ) ;
42
48
listeners . forEach ( listener => listener . remove ( ) ) ;
43
49
return res ;
44
50
} )
45
51
. catch ( err => {
46
- console . log ( 'Got an error ->' , err ) ;
47
- } )
52
+ this . log . error ( 'Error downloading ' , path , ' to ' , downloadPath , '. Error: ' , err ) ;
53
+ throw err ;
54
+ } ) ;
48
55
}
49
56
}
50
57
@@ -79,12 +86,13 @@ export default class Storage extends Base {
79
86
* @return {Promise }
80
87
*/
81
88
uploadFile ( name : string , filepath : string , metadata : Object = { } , cb : ( evt : Object ) = > Object ) : Promise < Object > {
89
+ this. log . debug ( 'uploadFile(' , filepath , ') -> ' , name ) ;
82
90
let callback = cb ;
83
91
if ( ! callback || typeof callback !== 'function' ) {
84
92
callback = ( evt : Object ) = > ( { } ) ;
85
93
}
86
94
87
- filepath = filepath . replace ( " file://" , "" ) ;
95
+ filepath = filepath . replace ( ' file://' , '' ) ;
88
96
89
97
const listeners = [ ] ;
90
98
listeners . push ( this . _addListener ( 'upload_progress' , callback ) ) ;
@@ -94,6 +102,10 @@ export default class Storage extends Base {
94
102
. then ( ( res ) => {
95
103
listeners . forEach ( listener => listener . remove ( ) ) ;
96
104
return res ;
105
+ } )
106
+ . catch ( err => {
107
+ this . log . error ( 'Error uploading file ' , name , ' to ' , filepath , '. Error: ' , err ) ;
108
+ throw err ;
97
109
} ) ;
98
110
}
99
111
0 commit comments