@@ -258,9 +258,8 @@ export async function upload(
258258 } ;
259259}
260260
261-
262261/**
263- * Uploads a zip file to the specified bucket using the firebasestorage api.
262+ * Uploads a zip or tar file to the specified bucket using the firebasestorage api.
264263 */
265264export async function uploadObject (
266265 /** Source with file (name) to upload, and stream of file. */
@@ -273,12 +272,16 @@ export async function uploadObject(
273272 object : string ;
274273 generation : string | null ;
275274} > {
276- if ( contentType == ContentType . TAR ) {
277- if ( path . extname ( source . file ) !== ".tar.gz" ) {
278- throw new FirebaseError ( `Expected a file name ending in .tar.gz, got ${ source . file } ` ) ;
279- }
280- } else if ( path . extname ( source . file ) !== ".zip" ) {
281- throw new FirebaseError ( `Expected a file name ending in .zip, got ${ source . file } ` ) ;
275+ switch ( contentType ) {
276+ case ContentType . TAR :
277+ if ( ! source . file . endsWith ( ".tar.gz" ) ) {
278+ throw new FirebaseError ( `Expected a file name ending in .tar.gz, got ${ source . file } ` ) ;
279+ }
280+ break ;
281+ default :
282+ if ( path . extname ( source . file ) !== ".zip" ) {
283+ throw new FirebaseError ( `Expected a file name ending in .zip, got ${ source . file } ` ) ;
284+ }
282285 }
283286
284287 const localAPIClient = new Client ( { urlPrefix : storageOrigin ( ) } ) ;
@@ -287,7 +290,8 @@ export async function uploadObject(
287290 method : "PUT" ,
288291 path : location ,
289292 headers : {
290- "Content-Type" : contentType == ContentType . TAR ? "application/octet-stream" : "application/zip" ,
293+ "Content-Type" :
294+ contentType === ContentType . TAR ? "application/octet-stream" : "application/zip" ,
291295 "x-goog-content-length-range" : "0,123289600" ,
292296 } ,
293297 body : source . stream ,
0 commit comments