@aws-amplify/storage 4.4.29 → 4.4.30-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.5.1](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.5.0...@aws-amplify/storage@4.5.1) (2022-08-01)
7
+
8
+ **Note:** Version bump only for package @aws-amplify/storage
9
+
10
+
11
+
12
+
13
+
14
+ # [4.5.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.4.29...@aws-amplify/storage@4.5.0) (2022-07-28)
15
+
16
+
17
+ ### Features
18
+
19
+ * **@aws-amplify/storage:** Access all files from S3 with List API ([#10095](https://github.com/aws-amplify/amplify-js/issues/10095)) ([366c32e](https://github.com/aws-amplify/amplify-js/commit/366c32e2d87d73210bbd01ca1da55a5899f5a503))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [4.4.29](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.4.28...@aws-amplify/storage@4.4.29) (2022-07-21)
7
26
 
8
27
  **Note:** Version bump only for package @aws-amplify/storage
@@ -48588,6 +48588,41 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
48588
48588
  };
48589
48589
  }
48590
48590
  };
48591
+
48592
+ var __read = undefined && undefined.__read || function (o, n) {
48593
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
48594
+ if (!m) return o;
48595
+ var i = m.call(o),
48596
+ r,
48597
+ ar = [],
48598
+ e;
48599
+
48600
+ try {
48601
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
48602
+ ar.push(r.value);
48603
+ }
48604
+ } catch (error) {
48605
+ e = {
48606
+ error: error
48607
+ };
48608
+ } finally {
48609
+ try {
48610
+ if (r && !r.done && (m = i["return"])) m.call(i);
48611
+ } finally {
48612
+ if (e) throw e.error;
48613
+ }
48614
+ }
48615
+
48616
+ return ar;
48617
+ };
48618
+
48619
+ var __spread = undefined && undefined.__spread || function () {
48620
+ for (var ar = [], i = 0; i < arguments.length; i++) {
48621
+ ar = ar.concat(__read(arguments[i]));
48622
+ }
48623
+
48624
+ return ar;
48625
+ };
48591
48626
  /*
48592
48627
  * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
48593
48628
  *
@@ -49221,6 +49256,45 @@ function () {
49221
49256
  });
49222
49257
  });
49223
49258
  };
49259
+
49260
+ AWSS3Provider.prototype._list = function (params, opt, prefix) {
49261
+ return __awaiter(this, void 0, void 0, function () {
49262
+ var result, s3, listObjectsV2Command, response;
49263
+ return __generator(this, function (_a) {
49264
+ switch (_a.label) {
49265
+ case 0:
49266
+ result = {
49267
+ contents: [],
49268
+ nextToken: ''
49269
+ };
49270
+ s3 = this._createNewS3Client(opt);
49271
+ listObjectsV2Command = new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["ListObjectsV2Command"](__assign({}, params));
49272
+ return [4
49273
+ /*yield*/
49274
+ , s3.send(listObjectsV2Command)];
49275
+
49276
+ case 1:
49277
+ response = _a.sent();
49278
+
49279
+ if (response && response.Contents) {
49280
+ result.contents = response.Contents.map(function (item) {
49281
+ return {
49282
+ key: item.Key.substr(prefix.length),
49283
+ eTag: item.ETag,
49284
+ lastModified: item.LastModified,
49285
+ size: item.Size
49286
+ };
49287
+ });
49288
+ result.nextToken = response.NextContinuationToken;
49289
+ }
49290
+
49291
+ return [2
49292
+ /*return*/
49293
+ , result];
49294
+ }
49295
+ });
49296
+ });
49297
+ };
49224
49298
  /**
49225
49299
  * List bucket objects relative to the level and prefix specified
49226
49300
  * @param {string} path - the path that contains objects
@@ -49232,7 +49306,7 @@ function () {
49232
49306
 
49233
49307
  AWSS3Provider.prototype.list = function (path, config) {
49234
49308
  return __awaiter(this, void 0, void 0, function () {
49235
- var credentialsOK, opt, bucket, track, maxKeys, prefix, final_path, s3, params, listObjectsCommand, response, list, error_5;
49309
+ var credentialsOK, opt, bucket, track, maxKeys, prefix, final_path, list, token, listResult, params, error_5;
49236
49310
  return __generator(this, function (_a) {
49237
49311
  switch (_a.label) {
49238
49312
  case 0:
@@ -49251,38 +49325,62 @@ function () {
49251
49325
  bucket = opt.bucket, track = opt.track, maxKeys = opt.maxKeys;
49252
49326
  prefix = this._prefix(opt);
49253
49327
  final_path = prefix + path;
49254
- s3 = this._createNewS3Client(opt);
49255
49328
  logger.debug('list ' + path + ' from ' + final_path);
49329
+ _a.label = 2;
49330
+
49331
+ case 2:
49332
+ _a.trys.push([2, 10,, 11]);
49333
+
49334
+ list = [];
49335
+ token = void 0;
49336
+ listResult = void 0;
49256
49337
  params = {
49257
49338
  Bucket: bucket,
49258
49339
  Prefix: final_path,
49259
- MaxKeys: maxKeys
49340
+ MaxKeys: 1000
49260
49341
  };
49261
- listObjectsCommand = new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["ListObjectsCommand"](params);
49262
- _a.label = 2;
49263
-
49264
- case 2:
49265
- _a.trys.push([2, 4,, 5]);
49342
+ if (!(maxKeys === 'ALL')) return [3
49343
+ /*break*/
49344
+ , 7];
49345
+ _a.label = 3;
49266
49346
 
49347
+ case 3:
49348
+ params.ContinuationToken = token;
49349
+ params.MaxKeys = 1000;
49267
49350
  return [4
49268
49351
  /*yield*/
49269
- , s3.send(listObjectsCommand)];
49352
+ , this._list(params, opt, prefix)];
49270
49353
 
49271
- case 3:
49272
- response = _a.sent();
49273
- list = [];
49354
+ case 4:
49355
+ listResult = _a.sent();
49356
+ list.push.apply(list, __spread(listResult.contents));
49357
+ if (listResult.nextToken) token = listResult.nextToken;
49358
+ _a.label = 5;
49274
49359
 
49275
- if (response && response.Contents) {
49276
- list = response.Contents.map(function (item) {
49277
- return {
49278
- key: item.Key.substr(prefix.length),
49279
- eTag: item.ETag,
49280
- lastModified: item.LastModified,
49281
- size: item.Size
49282
- };
49283
- });
49284
- }
49360
+ case 5:
49361
+ if (listResult.nextToken) return [3
49362
+ /*break*/
49363
+ , 3];
49364
+ _a.label = 6;
49285
49365
 
49366
+ case 6:
49367
+ return [3
49368
+ /*break*/
49369
+ , 9];
49370
+
49371
+ case 7:
49372
+ maxKeys < 1000 || typeof maxKeys === 'string' ? params.MaxKeys = maxKeys : params.MaxKeys = 1000;
49373
+ return [4
49374
+ /*yield*/
49375
+ , this._list(params, opt, prefix)];
49376
+
49377
+ case 8:
49378
+ listResult = _a.sent();
49379
+ list.push.apply(list, __spread(listResult.contents));
49380
+ if (maxKeys > 1000) logger.warn("maxkeys can be from 0 - 1000 or 'ALL'. To list all files you can set maxKeys to 'ALL'.");
49381
+ _a.label = 9;
49382
+
49383
+ case 9:
49286
49384
  Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'list', {
49287
49385
  method: 'list',
49288
49386
  result: 'success'
@@ -49292,7 +49390,7 @@ function () {
49292
49390
  /*return*/
49293
49391
  , list];
49294
49392
 
49295
- case 4:
49393
+ case 10:
49296
49394
  error_5 = _a.sent();
49297
49395
  logger.warn('list error', error_5);
49298
49396
  Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'list', {
@@ -49301,7 +49399,7 @@ function () {
49301
49399
  }, null, "Listing items failed: " + error_5.message);
49302
49400
  throw error_5;
49303
49401
 
49304
- case 5:
49402
+ case 11:
49305
49403
  return [2
49306
49404
  /*return*/
49307
49405
  ];