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 {
127127 endOffset ?: string ;
128128 includeTrailingDelimiter ?: boolean ;
129129 prefix ?: string ;
130+ matchGlob ?: string ;
130131 maxApiCalls ?: number ;
131132 maxResults ?: number ;
132133 pageToken ?: string ;
@@ -2528,6 +2529,8 @@ class Bucket extends ServiceObject {
25282529 * in addition to the relevant part of the object name appearing in prefixes[].
25292530 * @property {string } [prefix] Filter results to objects whose names begin
25302531 * with this prefix.
2532+ * @property {string } [matchGlob] A glob pattern used to filter results,
2533+ * for example foo*bar
25312534 * @property {number } [maxApiCalls] Maximum number of API calls to make.
25322535 * @property {number } [maxResults] Maximum number of items plus prefixes to
25332536 * return per call.
Original file line number Diff line number Diff line change @@ -3057,6 +3057,28 @@ describe('storage', () => {
30573057 } ) ;
30583058 } ) ;
30593059
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+
30603082 it ( 'should paginate the list' , async ( ) => {
30613083 const query = {
30623084 maxResults : NEW_FILES . length - 1 ,
You can’t perform that action at this time.
0 commit comments