MathieuLoutre / mock-aws-s3

Library to mock the AWS SDK for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for ContinuationToken?

adrian-kriegel opened this issue · comments

I have noticed that listObjectsV2 does not return NextContinuationToken which is required when iterating through larger sets of objects on S3.
The response looks like this:

{
      Contents: [
        {
          Key: 'file_0',
          ETag: '"cc6c6102174b3050bc3397c724f00f63"',
          LastModified: 2022-08-17T13:10:29.351Z,
          Size: 3
        },
        {
          Key: 'file_1',
          ETag: '"cc6c6102174b3050bc3397c724f00f63"',
          LastModified: 2022-08-17T13:10:29.351Z,
          Size: 3
        }
      ],
      CommonPrefixes: [ { Prefix: '/' } ],
      IsTruncated: true,
      NextContinuationToken: undefined,
      ContinuationToken: undefined,
      StartAfter: undefined
}

Note that while the tokens are missing, isTruncated is still set to true, which would lead to an infinite loop in many applications.

Looking at the code, this should be supported. But it requires Delimiter to be set to some arbitrary character.

mock.js line 228:

		if (truncated && search.Delimiter) {
			result.NextMarker = _.last(result.Contents).Key
		}

Is this also the behavior expected from AWS S3?