@aws-amplify/ui-react-storage 3.1.6 → 3.2.0
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/dist/esm/components/StorageManager/StorageManager.mjs +2 -1
- package/dist/esm/components/StorageManager/hooks/useUploadFiles/useUploadFiles.mjs +3 -1
- package/dist/esm/components/StorageManager/utils/getInput.mjs +2 -2
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +8 -5
- package/dist/types/components/StorageManager/hooks/useUploadFiles/useUploadFiles.d.ts +2 -2
- package/dist/types/components/StorageManager/types.d.ts +3 -0
- package/dist/types/components/StorageManager/utils/getInput.d.ts +2 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
|
@@ -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
|
|
|
@@ -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`
|
package/dist/esm/version.mjs
CHANGED
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.
|
|
36
|
+
const VERSION = '3.2.0';
|
|
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';
|
|
@@ -404,7 +404,7 @@ const resolveFile = ({ processFile, ...input }) => {
|
|
|
404
404
|
});
|
|
405
405
|
};
|
|
406
406
|
|
|
407
|
-
const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, }) => {
|
|
407
|
+
const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, useAccelerateEndpoint, }) => {
|
|
408
408
|
return async () => {
|
|
409
409
|
const hasCallbackPath = ui.isTypedFunction(path);
|
|
410
410
|
const hasStringPath = ui.isString(path);
|
|
@@ -412,7 +412,7 @@ const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, pa
|
|
|
412
412
|
const { file: data, key: processedKey, ...rest } = await resolveFile({ file, key, processFile });
|
|
413
413
|
const contentType = file.type || 'binary/octet-stream';
|
|
414
414
|
// IMPORTANT: always pass `...rest` here for backwards compatibility
|
|
415
|
-
const options = { contentType, onProgress, ...rest };
|
|
415
|
+
const options = { contentType, onProgress, useAccelerateEndpoint, ...rest };
|
|
416
416
|
let inputResult;
|
|
417
417
|
if (hasKeyInput) {
|
|
418
418
|
// legacy handling of `path` is to prefix to `fileKey`
|
|
@@ -460,7 +460,7 @@ async function uploadFile({ input, onError, onStart, onComplete, }) {
|
|
|
460
460
|
return uploadTask;
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
-
function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, }) {
|
|
463
|
+
function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }) {
|
|
464
464
|
React__namespace.useEffect(() => {
|
|
465
465
|
const filesReadyToUpload = files.filter((file) => file.status === FileStatus.QUEUED);
|
|
466
466
|
if (filesReadyToUpload.length > maxFileCount) {
|
|
@@ -487,6 +487,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProce
|
|
|
487
487
|
onProgress,
|
|
488
488
|
path,
|
|
489
489
|
processFile,
|
|
490
|
+
useAccelerateEndpoint,
|
|
490
491
|
});
|
|
491
492
|
uploadFile({
|
|
492
493
|
input,
|
|
@@ -527,6 +528,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProce
|
|
|
527
528
|
setUploadSuccess,
|
|
528
529
|
processFile,
|
|
529
530
|
path,
|
|
531
|
+
useAccelerateEndpoint,
|
|
530
532
|
]);
|
|
531
533
|
}
|
|
532
534
|
|
|
@@ -660,7 +662,7 @@ const logger = ui.getLogger('Storage');
|
|
|
660
662
|
const MISSING_REQUIRED_PROPS_MESSAGE = '`StorageManager` requires a `maxFileCount` prop to be provided.';
|
|
661
663
|
const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE = '`StorageManager` does not allow usage of a `path` callback prop with an `accessLevel` prop.';
|
|
662
664
|
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) {
|
|
665
|
+
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
666
|
if (!maxFileCount) {
|
|
665
667
|
// eslint-disable-next-line no-console
|
|
666
668
|
console.warn(MISSING_REQUIRED_PROPS_MESSAGE);
|
|
@@ -727,6 +729,7 @@ const StorageManagerBase = React__namespace.forwardRef(function StorageManager({
|
|
|
727
729
|
setUploadSuccess,
|
|
728
730
|
processFile,
|
|
729
731
|
path,
|
|
732
|
+
useAccelerateEndpoint,
|
|
730
733
|
});
|
|
731
734
|
const onFilePickerChange = (event) => {
|
|
732
735
|
const { files } = event.target;
|
|
@@ -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>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.
|
|
1
|
+
export declare const VERSION = "3.2.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-storage",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
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
|
|
43
|
-
"@aws-amplify/ui-react": "6.
|
|
44
|
-
"@aws-amplify/ui-react-core": "3.0.
|
|
42
|
+
"@aws-amplify/ui": "6.1.0",
|
|
43
|
+
"@aws-amplify/ui-react": "6.2.0",
|
|
44
|
+
"@aws-amplify/ui-react-core": "3.0.18",
|
|
45
45
|
"lodash": "4.17.21",
|
|
46
46
|
"tslib": "^2.5.2"
|
|
47
47
|
},
|