File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -85,22 +85,19 @@ <h6>File URL:</h6>
85
85
} ;
86
86
87
87
// Push to child path.
88
- var uploadTask = storageRef . child ( 'images/' + file . name ) . put ( file , metadata ) ;
89
-
90
- // Listen for errors and completion of the upload.
91
88
// [START oncomplete]
92
- uploadTask . on ( 'state_changed' , null , function ( error ) {
93
- // [START onfailure]
94
- console . error ( 'Upload failed:' , error ) ;
95
- // [END onfailure]
96
- } , function ( ) {
97
- console . log ( 'Uploaded' , uploadTask . snapshot . totalBytes , 'bytes.' ) ;
98
- console . log ( uploadTask . snapshot . metadata ) ;
99
- var url = uploadTask . snapshot . metadata . downloadURLs [ 0 ] ;
89
+ storageRef . child ( 'images/' + file . name ) . put ( file , metadata ) . then ( function ( snapshot ) {
90
+ console . log ( 'Uploaded' , snapshot . totalBytes , 'bytes.' ) ;
91
+ console . log ( snapshot . metadata ) ;
92
+ var url = snapshot . metadata . downloadURLs [ 0 ] ;
100
93
console . log ( 'File available at' , url ) ;
101
94
// [START_EXCLUDE]
102
95
document . getElementById ( 'linkbox' ) . innerHTML = '<a href="' + url + '">Click For File</a>' ;
103
96
// [END_EXCLUDE]
97
+ } ) . catch ( function ( error ) {
98
+ // [START onfailure]
99
+ console . error ( 'Upload failed:' , error ) ;
100
+ // [END onfailure]
104
101
} ) ;
105
102
// [END oncomplete]
106
103
}
You can’t perform that action at this time.
0 commit comments