File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ export interface GetFilesOptions {
127
127
endOffset ?: string ;
128
128
includeTrailingDelimiter ?: boolean ;
129
129
prefix ?: string ;
130
+ matchGlob ?: string ;
130
131
maxApiCalls ?: number ;
131
132
maxResults ?: number ;
132
133
pageToken ?: string ;
@@ -2528,6 +2529,8 @@ class Bucket extends ServiceObject {
2528
2529
* in addition to the relevant part of the object name appearing in prefixes[].
2529
2530
* @property {string } [prefix] Filter results to objects whose names begin
2530
2531
* with this prefix.
2532
+ * @property {string } [matchGlob] A glob pattern used to filter results,
2533
+ * for example foo*bar
2531
2534
* @property {number } [maxApiCalls] Maximum number of API calls to make.
2532
2535
* @property {number } [maxResults] Maximum number of items plus prefixes to
2533
2536
* return per call.
Original file line number Diff line number Diff line change @@ -3057,6 +3057,28 @@ describe('storage', () => {
3057
3057
} ) ;
3058
3058
} ) ;
3059
3059
3060
+ it ( 'should only get files matching the supplied matchGlob argument' , async ( ) => {
3061
+ let expectedFileNames = [ 'CloudLogo1' , 'CloudLogo2' , 'CloudLogo3' ] ;
3062
+ let [ files ] = await bucket . getFiles ( { matchGlob : 'CloudLogo*' } ) ;
3063
+ assert . strictEqual ( files . length , expectedFileNames . length ) ;
3064
+ for ( const curFile of files ) {
3065
+ assert . strictEqual ( expectedFileNames . includes ( curFile . name ) , true ) ;
3066
+ }
3067
+
3068
+ expectedFileNames = [
3069
+ `${ DIRECTORY_NAME } /CloudLogo4` ,
3070
+ `${ DIRECTORY_NAME } /CloudLogo5` ,
3071
+ `${ DIRECTORY_NAME } /inner/CloudLogo6` ,
3072
+ ] ;
3073
+ [ files ] = await bucket . getFiles ( {
3074
+ matchGlob : `${ DIRECTORY_NAME } /**/CloudLogo*` ,
3075
+ } ) ;
3076
+ assert . strictEqual ( files . length , expectedFileNames . length ) ;
3077
+ for ( const curFile of files ) {
3078
+ assert . strictEqual ( expectedFileNames . includes ( curFile . name ) , true ) ;
3079
+ }
3080
+ } ) ;
3081
+
3060
3082
it ( 'should paginate the list' , async ( ) => {
3061
3083
const query = {
3062
3084
maxResults : NEW_FILES . length - 1 ,
You can’t perform that action at this time.
0 commit comments