File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,14 @@ interface FirebaseStorageConfig {
99 bucketName : string ;
1010 basePath ?: string ;
1111 uploadOptions ?: UploadOptions ;
12+ domainName ?: string ;
1213}
1314
1415export default class FirebaseStorageAdapter extends BaseAdapter {
1516 bucket : Bucket ;
1617 uploadOptions ?: UploadOptions ;
1718 basePath : string ;
19+ domainName ?: string ;
1820
1921 constructor ( config : FirebaseStorageConfig ) {
2022 super ( ) ;
@@ -25,6 +27,7 @@ export default class FirebaseStorageAdapter extends BaseAdapter {
2527 this . bucket = app . storage ( ) . bucket ( ) ;
2628 this . uploadOptions = config . uploadOptions ;
2729 this . basePath = config . basePath ?? '' ;
30+ this . domainName = config . domainName ;
2831 }
2932
3033 async exists ( fileName : string , _targetDir : string ) : Promise < boolean > {
@@ -47,6 +50,16 @@ export default class FirebaseStorageAdapter extends BaseAdapter {
4750 ...( this . uploadOptions ? this . uploadOptions : defaultUploadOptions ) ,
4851 destination : pathToSave . split ( sep ) . join ( posix . sep ) ,
4952 } ;
53+ const data = await this . bucket . upload ( image . path , uploadOptions ) ;
54+ if ( this . domainName ) {
55+ const domainName = new URL ( this . domainName ) ;
56+ const downloadPath = new URL ( data [ 1 ] . name , domainName ) . toString ( ) ;
57+ console . log ( { downloadPath } ) ;
58+ return downloadPath ;
59+ }
60+ const link = data [ 1 ] . mediaLink ;
61+ console . log ( { link } ) ;
62+ return link ;
5063 }
5164
5265 serve ( ) {
You can’t perform that action at this time.
0 commit comments