Skip to content

Commit 60885b7

Browse files
authored
Revert "fix(storage): omit subPathStrategy when prefix is defined (aws-amplify#13614)
Revert "fix(storage): omit subPathStrategy when prefix is defined (aws-amplify#13606)" This reverts commit d3b9546.
1 parent d3b9546 commit 60885b7

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

packages/storage/src/providers/s3/apis/internal/list.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ import {
2020
resolveS3ConfigAndInput,
2121
validateStorageOperationInputWithPrefix,
2222
} from '../../utils';
23-
import {
24-
ListAllOptionsWithPath,
25-
ListPaginateOptionsWithPath,
26-
ResolvedS3Config,
27-
} from '../../types/options';
23+
import { ResolvedS3Config } from '../../types/options';
2824
import {
2925
ListObjectsV2Input,
3026
ListObjectsV2Output,
@@ -34,6 +30,7 @@ import { getStorageUserAgentValue } from '../../utils/userAgent';
3430
import { logger } from '../../../../utils';
3531
import { DEFAULT_DELIMITER, STORAGE_INPUT_PREFIX } from '../../utils/constants';
3632
import { CommonPrefix } from '../../utils/client/types';
33+
import { StorageSubpathStrategy } from '../../../../types';
3734

3835
const MAX_PAGE_SIZE = 1000;
3936

@@ -79,13 +76,12 @@ export const list = async (
7976
} ${anyOptions?.nextToken ? `nextToken: ${anyOptions?.nextToken}` : ''}.`,
8077
);
8178
}
82-
8379
const listParams = {
8480
Bucket: bucket,
8581
Prefix: isInputWithPrefix ? `${generatedPrefix}${objectKey}` : objectKey,
8682
MaxKeys: options?.listAll ? undefined : options?.pageSize,
8783
ContinuationToken: options?.listAll ? undefined : options?.nextToken,
88-
Delimiter: getDelimiter(options),
84+
Delimiter: getDelimiter(options.subpathStrategy),
8985
};
9086
logger.debug(`listing items from "${listParams.Prefix}"`);
9187

@@ -267,9 +263,9 @@ const mapCommonPrefixesToExcludedSubpaths = (
267263
};
268264

269265
const getDelimiter = (
270-
options?: ListAllOptionsWithPath | ListPaginateOptionsWithPath,
266+
subpathStrategy?: StorageSubpathStrategy,
271267
): string | undefined => {
272-
if (options?.subpathStrategy?.strategy === 'exclude') {
273-
return options?.subpathStrategy?.delimiter ?? DEFAULT_DELIMITER;
268+
if (subpathStrategy?.strategy === 'exclude') {
269+
return subpathStrategy?.delimiter ?? DEFAULT_DELIMITER;
274270
}
275271
};

packages/storage/src/providers/s3/types/options.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,17 @@ export type RemoveOptions = WriteOptions & CommonOptions;
7070
* @deprecated Use {@link ListAllOptionsWithPath} instead.
7171
* Input options type with prefix for S3 list all API.
7272
*/
73-
export type ListAllOptionsWithPrefix = Omit<
74-
StorageListAllOptions & ReadOptions & CommonOptions,
75-
'subpathStrategy'
76-
>;
73+
export type ListAllOptionsWithPrefix = StorageListAllOptions &
74+
ReadOptions &
75+
CommonOptions;
7776

7877
/**
7978
* @deprecated Use {@link ListPaginateOptionsWithPath} instead.
8079
* Input options type with prefix for S3 list API to paginate items.
8180
*/
82-
export type ListPaginateOptionsWithPrefix = Omit<
83-
StorageListPaginateOptions & ReadOptions & CommonOptions,
84-
'subpathStrategy'
85-
>;
81+
export type ListPaginateOptionsWithPrefix = StorageListPaginateOptions &
82+
ReadOptions &
83+
CommonOptions;
8684

8785
/**
8886
* Input options type with path for S3 list all API.

packages/storage/src/providers/s3/types/outputs.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ export type GetPropertiesWithPathOutput = ItemBase & StorageItemWithPath;
9494
* @deprecated Use {@link ListAllWithPathOutput} instead.
9595
* Output type for S3 list API. Lists all bucket objects.
9696
*/
97-
export type ListAllOutput = Omit<
98-
StorageListOutput<ListOutputItem>,
99-
'excludedSubpaths'
100-
>;
97+
export type ListAllOutput = StorageListOutput<ListOutputItem>;
10198

10299
/**
103100
* Output type with path for S3 list API. Lists all bucket objects.
@@ -108,10 +105,7 @@ export type ListAllWithPathOutput = StorageListOutput<ListOutputItemWithPath>;
108105
* @deprecated Use {@link ListPaginateWithPathOutput} instead.
109106
* Output type for S3 list API. Lists bucket objects with pagination.
110107
*/
111-
export type ListPaginateOutput = Omit<
112-
StorageListOutput<ListOutputItem>,
113-
'excludedSubpaths'
114-
> & {
108+
export type ListPaginateOutput = StorageListOutput<ListOutputItem> & {
115109
nextToken?: string;
116110
};
117111

0 commit comments

Comments
 (0)