@aws-amplify/ui-react-storage 3.1.6 → 3.2.1

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.
@@ -23,7 +23,7 @@ const logger = getLogger('Storage');
23
23
  const MISSING_REQUIRED_PROPS_MESSAGE = '`StorageManager` requires a `maxFileCount` prop to be provided.';
24
24
  const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE = '`StorageManager` does not allow usage of a `path` callback prop with an `accessLevel` prop.';
25
25
  const ACCESS_LEVEL_DEPRECATION_MESSAGE = '`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/storagemanager';
26
- const StorageManagerBase = React.forwardRef(function StorageManager({ acceptedFileTypes = [], accessLevel, autoUpload = true, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, }, ref) {
26
+ const StorageManagerBase = React.forwardRef(function StorageManager({ acceptedFileTypes = [], accessLevel, autoUpload = true, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
27
27
  if (!maxFileCount) {
28
28
  // eslint-disable-next-line no-console
29
29
  console.warn(MISSING_REQUIRED_PROPS_MESSAGE);
@@ -90,6 +90,7 @@ const StorageManagerBase = React.forwardRef(function StorageManager({ acceptedFi
90
90
  setUploadSuccess,
91
91
  processFile,
92
92
  path,
93
+ useAccelerateEndpoint,
93
94
  });
94
95
  const onFilePickerChange = (event) => {
95
96
  const { files } = event.target;
@@ -4,7 +4,7 @@ import { getInput } from '../../utils/getInput.mjs';
4
4
  import { uploadFile } from '../../utils/uploadFile.mjs';
5
5
  import { FileStatus } from '../../types.mjs';
6
6
 
7
- function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, }) {
7
+ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }) {
8
8
  React.useEffect(() => {
9
9
  const filesReadyToUpload = files.filter((file) => file.status === FileStatus.QUEUED);
10
10
  if (filesReadyToUpload.length > maxFileCount) {
@@ -31,6 +31,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProce
31
31
  onProgress,
32
32
  path,
33
33
  processFile,
34
+ useAccelerateEndpoint,
34
35
  });
35
36
  uploadFile({
36
37
  input,
@@ -71,6 +72,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProce
71
72
  setUploadSuccess,
72
73
  processFile,
73
74
  path,
75
+ useAccelerateEndpoint,
74
76
  ]);
75
77
  }
76
78
 
@@ -1,9 +1,6 @@
1
1
  import React__default from 'react';
2
- import { ComponentClassName } from '@aws-amplify/ui';
2
+ import { ComponentClassName, humanFileSize } from '@aws-amplify/ui';
3
3
  import { View, Text } from '@aws-amplify/ui-react';
4
- import { humanFileSize } from '../../utils/humanFileSize.mjs';
5
- import 'aws-amplify/auth';
6
- import 'aws-amplify/storage';
7
4
 
8
5
  const UploadDetails = ({ displayName, fileSize, }) => {
9
6
  return (React__default.createElement(React__default.Fragment, null,
@@ -1,4 +1,4 @@
1
- import { humanFileSize } from './humanFileSize.mjs';
1
+ import { humanFileSize } from '@aws-amplify/ui';
2
2
 
3
3
  const checkMaxFileSize = ({ file, getFileSizeErrorText, maxFileSize, }) => {
4
4
  if (maxFileSize === undefined)
@@ -2,7 +2,7 @@ import { fetchAuthSession } from 'aws-amplify/auth';
2
2
  import { isTypedFunction, isString } from '@aws-amplify/ui';
3
3
  import { resolveFile } from './resolveFile.mjs';
4
4
 
5
- const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, }) => {
5
+ const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, useAccelerateEndpoint, }) => {
6
6
  return async () => {
7
7
  const hasCallbackPath = isTypedFunction(path);
8
8
  const hasStringPath = isString(path);
@@ -10,7 +10,7 @@ const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, pa
10
10
  const { file: data, key: processedKey, ...rest } = await resolveFile({ file, key, processFile });
11
11
  const contentType = file.type || 'binary/octet-stream';
12
12
  // IMPORTANT: always pass `...rest` here for backwards compatibility
13
- const options = { contentType, onProgress, ...rest };
13
+ const options = { contentType, onProgress, useAccelerateEndpoint, ...rest };
14
14
  let inputResult;
15
15
  if (hasKeyInput) {
16
16
  // legacy handling of `path` is to prefix to `fileKey`
@@ -1,3 +1,3 @@
1
- const VERSION = '3.1.6';
1
+ const VERSION = '3.2.1';
2
2
 
3
3
  export { VERSION };
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ function _interopNamespace(e) {
33
33
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
34
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
35
35
 
36
- const VERSION = '3.1.6';
36
+ const VERSION = '3.2.1';
37
37
 
38
38
  const MISSING_REQUIRED_PROP_MESSAGE = '`StorageImage` requires either an `imgKey` or `path` prop.';
39
39
  const HAS_DEPRECATED_PROPS_MESSAGE = '`imgKey`, `accessLevel`, and `identityId` will be replaced with `path` in a future major version. See https://ui.docs.amplify.aws/react/connected-components/storage/storageimage#props';
@@ -286,39 +286,11 @@ function useStorageManager(defaultFiles = []) {
286
286
  };
287
287
  }
288
288
 
289
- /**
290
- * Format bytes as human-readable text.
291
- *
292
- * @param bytes Number of bytes.
293
- * @param si True to use metric (SI) units, aka powers of 1000. False to use
294
- * binary (IEC), aka powers of 1024.
295
- * @param dp Number of decimal places to display.
296
- *
297
- * @return Formatted string.
298
- */
299
- function humanFileSize(bytes, si = false, dp = 1) {
300
- const thresh = si ? 1000 : 1024;
301
- if (Math.abs(bytes) < thresh) {
302
- return `${bytes} B`;
303
- }
304
- const units = si
305
- ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
306
- : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
307
- let unit = -1;
308
- const range = 10 ** dp;
309
- do {
310
- bytes /= thresh;
311
- ++unit;
312
- } while (Math.round(Math.abs(bytes) * range) / range >= thresh &&
313
- unit < units.length - 1);
314
- return bytes.toFixed(dp) + ' ' + units[unit];
315
- }
316
-
317
289
  const checkMaxFileSize = ({ file, getFileSizeErrorText, maxFileSize, }) => {
318
290
  if (maxFileSize === undefined)
319
291
  return '';
320
292
  if (file.size > maxFileSize) {
321
- return getFileSizeErrorText(humanFileSize(maxFileSize, true));
293
+ return getFileSizeErrorText(ui.humanFileSize(maxFileSize, true));
322
294
  }
323
295
  return '';
324
296
  };
@@ -404,7 +376,7 @@ const resolveFile = ({ processFile, ...input }) => {
404
376
  });
405
377
  };
406
378
 
407
- const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, }) => {
379
+ const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, useAccelerateEndpoint, }) => {
408
380
  return async () => {
409
381
  const hasCallbackPath = ui.isTypedFunction(path);
410
382
  const hasStringPath = ui.isString(path);
@@ -412,7 +384,7 @@ const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, pa
412
384
  const { file: data, key: processedKey, ...rest } = await resolveFile({ file, key, processFile });
413
385
  const contentType = file.type || 'binary/octet-stream';
414
386
  // IMPORTANT: always pass `...rest` here for backwards compatibility
415
- const options = { contentType, onProgress, ...rest };
387
+ const options = { contentType, onProgress, useAccelerateEndpoint, ...rest };
416
388
  let inputResult;
417
389
  if (hasKeyInput) {
418
390
  // legacy handling of `path` is to prefix to `fileKey`
@@ -460,7 +432,7 @@ async function uploadFile({ input, onError, onStart, onComplete, }) {
460
432
  return uploadTask;
461
433
  }
462
434
 
463
- function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, }) {
435
+ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }) {
464
436
  React__namespace.useEffect(() => {
465
437
  const filesReadyToUpload = files.filter((file) => file.status === FileStatus.QUEUED);
466
438
  if (filesReadyToUpload.length > maxFileCount) {
@@ -487,6 +459,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProce
487
459
  onProgress,
488
460
  path,
489
461
  processFile,
462
+ useAccelerateEndpoint,
490
463
  });
491
464
  uploadFile({
492
465
  input,
@@ -527,6 +500,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProce
527
500
  setUploadSuccess,
528
501
  processFile,
529
502
  path,
503
+ useAccelerateEndpoint,
530
504
  ]);
531
505
  }
532
506
 
@@ -576,7 +550,7 @@ const UploadDetails = ({ displayName, fileSize, }) => {
576
550
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
577
551
  React__default["default"].createElement(uiReact.View, { className: ui.ComponentClassName.StorageManagerFileMain },
578
552
  React__default["default"].createElement(uiReact.Text, { className: ui.ComponentClassName.StorageManagerFileName }, displayName)),
579
- React__default["default"].createElement(uiReact.Text, { as: "span", className: ui.ComponentClassName.StorageManagerFileSize }, fileSize ? humanFileSize(fileSize, true) : '')));
553
+ React__default["default"].createElement(uiReact.Text, { as: "span", className: ui.ComponentClassName.StorageManagerFileSize }, fileSize ? ui.humanFileSize(fileSize, true) : '')));
580
554
  };
581
555
 
582
556
  const FileThumbnail = ({ fileName, isImage, url, }) => {
@@ -660,7 +634,7 @@ const logger = ui.getLogger('Storage');
660
634
  const MISSING_REQUIRED_PROPS_MESSAGE = '`StorageManager` requires a `maxFileCount` prop to be provided.';
661
635
  const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE = '`StorageManager` does not allow usage of a `path` callback prop with an `accessLevel` prop.';
662
636
  const ACCESS_LEVEL_DEPRECATION_MESSAGE = '`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/storagemanager';
663
- const StorageManagerBase = React__namespace.forwardRef(function StorageManager({ acceptedFileTypes = [], accessLevel, autoUpload = true, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, }, ref) {
637
+ const StorageManagerBase = React__namespace.forwardRef(function StorageManager({ acceptedFileTypes = [], accessLevel, autoUpload = true, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
664
638
  if (!maxFileCount) {
665
639
  // eslint-disable-next-line no-console
666
640
  console.warn(MISSING_REQUIRED_PROPS_MESSAGE);
@@ -727,6 +701,7 @@ const StorageManagerBase = React__namespace.forwardRef(function StorageManager({
727
701
  setUploadSuccess,
728
702
  processFile,
729
703
  path,
704
+ useAccelerateEndpoint,
730
705
  });
731
706
  const onFilePickerChange = (event) => {
732
707
  const { files } = event.target;
package/dist/styles.css CHANGED
@@ -1640,9 +1640,8 @@ strong.amplify-text {
1640
1640
  padding-inline-start: var(--amplify-components-button-padding-inline-start);
1641
1641
  padding-inline-end: var(--amplify-components-button-padding-inline-end);
1642
1642
  transition: all var(--amplify-components-button-transition-duration);
1643
- -webkit-user-select: none;
1644
- -moz-user-select: none;
1645
- user-select: none;
1643
+ -moz-user-select: none;
1644
+ user-select: none;
1646
1645
  --amplify-internal-button-disabled-color: var(
1647
1646
  --amplify-components-button-disabled-color
1648
1647
  );
@@ -2663,58 +2662,50 @@ strong.amplify-text {
2663
2662
  background-color: var(--amplify-internal-button-disabled-background-color);
2664
2663
  border-color: var(--amplify-internal-button-disabled-border-color);
2665
2664
  color: var(--amplify-internal-button-disabled-color);
2666
- -webkit-text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2667
- text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2665
+ text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2668
2666
  cursor: not-allowed;
2669
2667
  }
2670
2668
  .amplify-button--disabled:hover {
2671
2669
  background-color: var(--amplify-internal-button-disabled-background-color);
2672
2670
  border-color: var(--amplify-internal-button-disabled-border-color);
2673
2671
  color: var(--amplify-internal-button-disabled-color);
2674
- -webkit-text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2675
- text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2672
+ text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2676
2673
  }
2677
2674
  .amplify-button--disabled :focus {
2678
2675
  background-color: var(--amplify-internal-button-disabled-background-color);
2679
2676
  border-color: var(--amplify-internal-button-disabled-border-color);
2680
2677
  color: var(--amplify-internal-button-disabled-color);
2681
- -webkit-text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2682
- text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2678
+ text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2683
2679
  }
2684
2680
  .amplify-button--disabled:active {
2685
2681
  background-color: var(--amplify-internal-button-disabled-background-color);
2686
2682
  border-color: var(--amplify-internal-button-disabled-border-color);
2687
2683
  color: var(--amplify-internal-button-disabled-color);
2688
- -webkit-text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2689
- text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2684
+ text-decoration: var(--amplify-internal-button-disabled-text-decoration);
2690
2685
  }
2691
2686
  .amplify-button--loading {
2692
2687
  background-color: var(--amplify-internal-button-loading-background-color);
2693
2688
  border-color: var(--amplify-internal-button-loading-border-color);
2694
2689
  color: var(--amplify-components-button-loading-color);
2695
- -webkit-text-decoration: var(--amplify-internal-button-loading-text-decoration);
2696
- text-decoration: var(--amplify-internal-button-loading-text-decoration);
2690
+ text-decoration: var(--amplify-internal-button-loading-text-decoration);
2697
2691
  }
2698
2692
  .amplify-button--loading:hover {
2699
2693
  background-color: var(--amplify-internal-button-loading-background-color);
2700
2694
  border-color: var(--amplify-internal-button-loading-border-color);
2701
2695
  color: var(--amplify-components-button-loading-color);
2702
- -webkit-text-decoration: var(--amplify-internal-button-loading-text-decoration);
2703
- text-decoration: var(--amplify-internal-button-loading-text-decoration);
2696
+ text-decoration: var(--amplify-internal-button-loading-text-decoration);
2704
2697
  }
2705
2698
  .amplify-button--loading:focus {
2706
2699
  background-color: var(--amplify-internal-button-loading-background-color);
2707
2700
  border-color: var(--amplify-internal-button-loading-border-color);
2708
2701
  color: var(--amplify-components-button-loading-color);
2709
- -webkit-text-decoration: var(--amplify-internal-button-loading-text-decoration);
2710
- text-decoration: var(--amplify-internal-button-loading-text-decoration);
2702
+ text-decoration: var(--amplify-internal-button-loading-text-decoration);
2711
2703
  }
2712
2704
  .amplify-button--loading:active {
2713
2705
  background-color: var(--amplify-internal-button-loading-background-color);
2714
2706
  border-color: var(--amplify-internal-button-loading-border-color);
2715
2707
  color: var(--amplify-components-button-loading-color);
2716
- -webkit-text-decoration: var(--amplify-internal-button-loading-text-decoration);
2717
- text-decoration: var(--amplify-internal-button-loading-text-decoration);
2708
+ text-decoration: var(--amplify-internal-button-loading-text-decoration);
2718
2709
  }
2719
2710
  .amplify-button__loader-wrapper {
2720
2711
  align-items: var(--amplify-components-button-loader-wrapper-align-items);
@@ -2862,9 +2853,8 @@ strong.amplify-text {
2862
2853
  outline-style: var(--amplify-components-fieldcontrol-outline-style);
2863
2854
  outline-width: var(--amplify-components-fieldcontrol-outline-width);
2864
2855
  outline-offset: var(--amplify-components-fieldcontrol-outline-offset);
2865
- -webkit-user-select: text;
2866
- -moz-user-select: text;
2867
- user-select: text;
2856
+ -moz-user-select: text;
2857
+ user-select: text;
2868
2858
  display: inline-block;
2869
2859
  --amplify-components-fieldcontrol-color: var(
2870
2860
  --amplify-components-input-color
@@ -2947,9 +2937,8 @@ strong.amplify-text {
2947
2937
  outline-style: var(--amplify-components-fieldcontrol-outline-style);
2948
2938
  outline-width: var(--amplify-components-fieldcontrol-outline-width);
2949
2939
  outline-offset: var(--amplify-components-fieldcontrol-outline-offset);
2950
- -webkit-user-select: text;
2951
- -moz-user-select: text;
2952
- user-select: text;
2940
+ -moz-user-select: text;
2941
+ user-select: text;
2953
2942
  white-space: pre-wrap;
2954
2943
  }
2955
2944
  .amplify-textarea:focus {
@@ -3013,29 +3002,24 @@ strong.amplify-text {
3013
3002
 
3014
3003
  .amplify-link {
3015
3004
  color: var(--amplify-components-link-color);
3016
- -webkit-text-decoration: var(--amplify-components-link-text-decoration);
3017
- text-decoration: var(--amplify-components-link-text-decoration);
3005
+ text-decoration: var(--amplify-components-link-text-decoration);
3018
3006
  cursor: pointer;
3019
3007
  }
3020
3008
  .amplify-link:visited {
3021
3009
  color: var(--amplify-components-link-visited-color);
3022
- -webkit-text-decoration: var(--amplify-components-link-visited-text-decoration);
3023
- text-decoration: var(--amplify-components-link-visited-text-decoration);
3010
+ text-decoration: var(--amplify-components-link-visited-text-decoration);
3024
3011
  }
3025
3012
  .amplify-link:active {
3026
3013
  color: var(--amplify-components-link-active-color);
3027
- -webkit-text-decoration: var(--amplify-components-link-active-text-decoration);
3028
- text-decoration: var(--amplify-components-link-active-text-decoration);
3014
+ text-decoration: var(--amplify-components-link-active-text-decoration);
3029
3015
  }
3030
3016
  .amplify-link:focus {
3031
3017
  color: var(--amplify-components-link-focus-color);
3032
- -webkit-text-decoration: var(--amplify-components-link-focus-text-decoration);
3033
- text-decoration: var(--amplify-components-link-focus-text-decoration);
3018
+ text-decoration: var(--amplify-components-link-focus-text-decoration);
3034
3019
  }
3035
3020
  .amplify-link:hover {
3036
3021
  color: var(--amplify-components-link-hover-color);
3037
- -webkit-text-decoration: var(--amplify-components-link-hover-text-decoration);
3038
- text-decoration: var(--amplify-components-link-hover-text-decoration);
3022
+ text-decoration: var(--amplify-components-link-hover-text-decoration);
3039
3023
  }
3040
3024
 
3041
3025
  .amplify-loader {
@@ -3466,16 +3450,14 @@ strong.amplify-text {
3466
3450
  font-weight: var(--amplify-components-breadcrumbs-link-font-weight);
3467
3451
  padding-inline: var(--amplify-components-breadcrumbs-link-padding-inline);
3468
3452
  padding-block: var(--amplify-components-breadcrumbs-link-padding-block);
3469
- -webkit-text-decoration: var(--amplify-components-breadcrumbs-link-text-decoration);
3470
- text-decoration: var(--amplify-components-breadcrumbs-link-text-decoration);
3453
+ text-decoration: var(--amplify-components-breadcrumbs-link-text-decoration);
3471
3454
  }
3472
3455
 
3473
3456
  .amplify-breadcrumbs__link--current {
3474
3457
  color: var(--amplify-components-breadcrumbs-link-current-color);
3475
3458
  font-size: var(--amplify-components-breadcrumbs-link-current-font-size);
3476
3459
  font-weight: var(--amplify-components-breadcrumbs-link-current-font-weight);
3477
- -webkit-text-decoration: var(--amplify-components-breadcrumbs-link-current-text-decoration);
3478
- text-decoration: var(--amplify-components-breadcrumbs-link-current-text-decoration);
3460
+ text-decoration: var(--amplify-components-breadcrumbs-link-current-text-decoration);
3479
3461
  }
3480
3462
 
3481
3463
  .amplify-card {
@@ -5025,9 +5007,8 @@ html[dir=rtl] .amplify-field-group__inner-start {
5025
5007
  padding-block: var(--amplify-components-sliderfield-padding-block);
5026
5008
  position: relative;
5027
5009
  touch-action: none;
5028
- -webkit-user-select: none;
5029
- -moz-user-select: none;
5030
- user-select: none;
5010
+ -moz-user-select: none;
5011
+ user-select: none;
5031
5012
  --amplify-internal-sliderfield-root-height: var(
5032
5013
  --amplify-components-sliderfield-thumb-height
5033
5014
  );
@@ -1,7 +1,7 @@
1
1
  import { PathCallback } from '../../utils';
2
2
  import { StorageManagerProps } from '../../types';
3
3
  import { UseStorageManager } from '../useStorageManager';
4
- export interface UseUploadFilesProps extends Pick<StorageManagerProps, 'isResumable' | 'onUploadSuccess' | 'onUploadError' | 'onUploadStart' | 'maxFileCount' | 'processFile'>, Pick<UseStorageManager, 'setUploadingFile' | 'setUploadProgress' | 'setUploadSuccess' | 'files'> {
4
+ export interface UseUploadFilesProps extends Pick<StorageManagerProps, 'isResumable' | 'onUploadSuccess' | 'onUploadError' | 'onUploadStart' | 'maxFileCount' | 'processFile' | 'useAccelerateEndpoint'>, Pick<UseStorageManager, 'setUploadingFile' | 'setUploadProgress' | 'setUploadSuccess' | 'files'> {
5
5
  accessLevel?: StorageManagerProps['accessLevel'];
6
6
  onProcessFileSuccess: (input: {
7
7
  id: string;
@@ -9,4 +9,4 @@ export interface UseUploadFilesProps extends Pick<StorageManagerProps, 'isResuma
9
9
  }) => void;
10
10
  path?: string | PathCallback;
11
11
  }
12
- export declare function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, }: UseUploadFilesProps): void;
12
+ export declare function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }: UseUploadFilesProps): void;
@@ -26,6 +26,7 @@ export type DefaultFile = Pick<StorageFile, 'key'>;
26
26
  export interface ProcessFileParams extends Record<string, any> {
27
27
  file: File;
28
28
  key: string;
29
+ useAccelerateEndpoint?: boolean;
29
30
  }
30
31
  export type ProcessFile = (params: ProcessFileParams) => Promise<ProcessFileParams> | ProcessFileParams;
31
32
  export interface StorageManagerHandle {
@@ -113,6 +114,7 @@ export interface StorageManagerProps {
113
114
  * Provided value is prefixed to the file `key` for each file
114
115
  */
115
116
  path?: string;
117
+ useAccelerateEndpoint?: boolean;
116
118
  }
117
119
  export interface StorageManagerPathProps extends Omit<StorageManagerProps, 'accessLevel' | 'path'> {
118
120
  /**
@@ -123,4 +125,5 @@ export interface StorageManagerPathProps extends Omit<StorageManagerProps, 'acce
123
125
  */
124
126
  path: string | PathCallback;
125
127
  accessLevel?: never;
128
+ useAccelerateEndpoint?: boolean;
126
129
  }
@@ -12,5 +12,6 @@ export interface GetInputParams {
12
12
  onProgress: NonNullable<UploadDataWithPathInput['options']>['onProgress'];
13
13
  path: string | PathCallback | undefined;
14
14
  processFile: ProcessFile | undefined;
15
+ useAccelerateEndpoint?: boolean;
15
16
  }
16
- export declare const getInput: ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, }: GetInputParams) => () => Promise<PathInput | UploadDataInput>;
17
+ export declare const getInput: ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, useAccelerateEndpoint, }: GetInputParams) => () => Promise<PathInput | UploadDataInput>;
@@ -1,6 +1,5 @@
1
1
  export { checkMaxFileSize } from './checkMaxFileSize';
2
2
  export { defaultStorageManagerDisplayText, StorageManagerDisplayText, StorageManagerDisplayTextDefault, } from './displayText';
3
3
  export { filterAllowedFiles } from './filterAllowedFiles';
4
- export { humanFileSize } from './humanFileSize';
5
4
  export { getInput } from './getInput';
6
5
  export { PathCallback, TaskEvent, TaskHandler, uploadFile, UploadTask, } from './uploadFile';
@@ -1 +1 @@
1
- export declare const VERSION = "3.1.6";
1
+ export declare const VERSION = "3.2.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-storage",
3
- "version": "3.1.6",
3
+ "version": "3.2.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {
@@ -39,9 +39,9 @@
39
39
  "typecheck": "tsc --noEmit"
40
40
  },
41
41
  "dependencies": {
42
- "@aws-amplify/ui": "6.0.17",
43
- "@aws-amplify/ui-react": "6.1.14",
44
- "@aws-amplify/ui-react-core": "3.0.17",
42
+ "@aws-amplify/ui": "6.2.0",
43
+ "@aws-amplify/ui-react": "6.2.1",
44
+ "@aws-amplify/ui-react-core": "3.0.19",
45
45
  "lodash": "4.17.21",
46
46
  "tslib": "^2.5.2"
47
47
  },
@@ -1,29 +0,0 @@
1
- /**
2
- * Format bytes as human-readable text.
3
- *
4
- * @param bytes Number of bytes.
5
- * @param si True to use metric (SI) units, aka powers of 1000. False to use
6
- * binary (IEC), aka powers of 1024.
7
- * @param dp Number of decimal places to display.
8
- *
9
- * @return Formatted string.
10
- */
11
- function humanFileSize(bytes, si = false, dp = 1) {
12
- const thresh = si ? 1000 : 1024;
13
- if (Math.abs(bytes) < thresh) {
14
- return `${bytes} B`;
15
- }
16
- const units = si
17
- ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
18
- : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
19
- let unit = -1;
20
- const range = 10 ** dp;
21
- do {
22
- bytes /= thresh;
23
- ++unit;
24
- } while (Math.round(Math.abs(bytes) * range) / range >= thresh &&
25
- unit < units.length - 1);
26
- return bytes.toFixed(dp) + ' ' + units[unit];
27
- }
28
-
29
- export { humanFileSize };
@@ -1,11 +0,0 @@
1
- /**
2
- * Format bytes as human-readable text.
3
- *
4
- * @param bytes Number of bytes.
5
- * @param si True to use metric (SI) units, aka powers of 1000. False to use
6
- * binary (IEC), aka powers of 1024.
7
- * @param dp Number of decimal places to display.
8
- *
9
- * @return Formatted string.
10
- */
11
- export declare function humanFileSize(bytes: number, si?: boolean, dp?: number): string;