diff --git a/packages/aws-amplify/package.json b/packages/aws-amplify/package.json index a3c44a89861..6104db0a485 100644 --- a/packages/aws-amplify/package.json +++ b/packages/aws-amplify/package.json @@ -485,7 +485,7 @@ "name": "[Storage] list (S3)", "path": "./dist/esm/storage/index.mjs", "import": "{ list }", - "limit": "14.94 kB" + "limit": "15.04 kB" }, { "name": "[Storage] remove (S3)", diff --git a/packages/storage/src/providers/s3/apis/internal/list.ts b/packages/storage/src/providers/s3/apis/internal/list.ts index 59f70e521bf..94fe8b049d1 100644 --- a/packages/storage/src/providers/s3/apis/internal/list.ts +++ b/packages/storage/src/providers/s3/apis/internal/list.ts @@ -201,7 +201,7 @@ const _listAllWithPath = async ({ return { items: listResult, - ...(subpaths.length > 0 ? { subpaths } : {}), + ...getOptionWithSubpaths(subpaths), }; }; @@ -233,7 +233,7 @@ const _listWithPath = async ({ if (!Contents) { return { items: [], - ...(subpaths && subpaths.length > 0 ? { subpaths } : {}), + ...getOptionWithSubpaths(subpaths), }; } @@ -245,7 +245,7 @@ const _listWithPath = async ({ size: item.Size, })), nextToken: NextContinuationToken, - ...(subpaths && subpaths.length > 0 ? { subpaths } : {}), + ...getOptionWithSubpaths(subpaths), }; }; @@ -266,3 +266,7 @@ function mapCommonPrefixesToSubpaths( return mappedSubpaths as Subpath[] | undefined; } + +function getOptionWithSubpaths(subpaths?: Subpath[]) { + return subpaths && subpaths.length > 0 ? { subpaths } : {}; +}