@@ -16,7 +16,12 @@ class StorageRef extends ReferenceBase {
1616
1717 downloadUrl ( ) : Promise < Object > {
1818 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+ } ) ;
2025 }
2126
2227 /**
@@ -36,15 +41,17 @@ class StorageRef extends ReferenceBase {
3641 listeners . push ( this . storage . _addListener ( 'download_resumed' , callback ) ) ;
3742
3843 const path = this . pathToString ( ) ;
44+ this . log . debug ( 'download(' , path , ') -> ' , downloadPath ) ;
3945 return promisify ( 'downloadFile' , FirestackStorage ) ( this . storage . storageUrl , path , downloadPath )
4046 . then ( ( res ) => {
41- console . log ( 'res --->' , res ) ;
47+ this . log . debug ( 'res --->' , res ) ;
4248 listeners . forEach ( listener => listener . remove ( ) ) ;
4349 return res ;
4450 } )
4551 . 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+ } ) ;
4855 }
4956}
5057
@@ -79,12 +86,13 @@ export default class Storage extends Base {
7986 * @return {Promise }
8087 */
8188 uploadFile ( name : string , filepath : string , metadata : Object = { } , cb : ( evt : Object ) = > Object ) : Promise < Object > {
89+ this. log . debug ( 'uploadFile(' , filepath , ') -> ' , name ) ;
8290 let callback = cb ;
8391 if ( ! callback || typeof callback !== 'function' ) {
8492 callback = ( evt : Object ) = > ( { } ) ;
8593 }
8694
87- filepath = filepath . replace ( " file://" , "" ) ;
95+ filepath = filepath . replace ( ' file://' , '' ) ;
8896
8997 const listeners = [ ] ;
9098 listeners . push ( this . _addListener ( 'upload_progress' , callback ) ) ;
@@ -94,6 +102,10 @@ export default class Storage extends Base {
94102 . then ( ( res ) => {
95103 listeners . forEach ( listener => listener . remove ( ) ) ;
96104 return res ;
105+ } )
106+ . catch ( err => {
107+ this . log . error ( 'Error uploading file ' , name , ' to ' , filepath , '. Error: ' , err ) ;
108+ throw err ;
97109 } ) ;
98110 }
99111
0 commit comments