@aws-amplify/ui-react-storage 3.3.2 → 3.3.4

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.
Files changed (58) hide show
  1. package/dist/esm/components/FileUploader/FileUploader.mjs +2 -4
  2. package/dist/esm/components/FileUploader/hooks/useFileUploader/actions.mjs +8 -5
  3. package/dist/esm/components/FileUploader/hooks/useFileUploader/reducer.mjs +16 -28
  4. package/dist/esm/components/FileUploader/hooks/useFileUploader/types.mjs +9 -8
  5. package/dist/esm/components/FileUploader/hooks/useFileUploader/useFileUploader.mjs +31 -44
  6. package/dist/esm/components/FileUploader/hooks/useUploadFiles/useUploadFiles.mjs +5 -9
  7. package/dist/esm/components/FileUploader/utils/getInput.mjs +1 -5
  8. package/dist/esm/components/StorageManager/StorageManager.mjs +9 -11
  9. package/dist/esm/components/StorageManager/ui/FileList/FileControl.mjs +1 -1
  10. package/dist/esm/components/StorageManager/ui/FileList/FileList.mjs +1 -1
  11. package/dist/esm/components/StorageManager/ui/FileList/FileStatusMessage.mjs +1 -1
  12. package/dist/esm/version.mjs +1 -1
  13. package/dist/index.js +115 -569
  14. package/dist/styles.css +62 -23
  15. package/dist/types/components/FileUploader/hooks/useFileUploader/actions.d.ts +4 -4
  16. package/dist/types/components/FileUploader/hooks/useFileUploader/types.d.ts +12 -10
  17. package/dist/types/components/FileUploader/hooks/useFileUploader/useFileUploader.d.ts +7 -10
  18. package/dist/types/components/FileUploader/hooks/useUploadFiles/useUploadFiles.d.ts +1 -5
  19. package/dist/types/components/FileUploader/index.d.ts +1 -1
  20. package/dist/types/components/FileUploader/types.d.ts +1 -1
  21. package/dist/types/components/FileUploader/utils/getInput.d.ts +1 -4
  22. package/dist/types/components/StorageManager/index.d.ts +1 -1
  23. package/dist/types/components/StorageManager/types.d.ts +2 -9
  24. package/dist/types/components/StorageManager/ui/DropZone/types.d.ts +1 -1
  25. package/dist/types/components/StorageManager/ui/FileList/types.d.ts +2 -2
  26. package/dist/types/components/StorageManager/ui/FileListFooter/FileListFooter.d.ts +1 -1
  27. package/dist/types/components/StorageManager/ui/FileListHeader/FileListHeader.d.ts +1 -1
  28. package/dist/types/components/index.d.ts +2 -2
  29. package/dist/types/index.d.ts +1 -1
  30. package/dist/types/version.d.ts +1 -1
  31. package/package.json +4 -4
  32. package/dist/esm/components/StorageManager/hooks/useStorageManager/actions.mjs +0 -39
  33. package/dist/esm/components/StorageManager/hooks/useStorageManager/reducer.mjs +0 -93
  34. package/dist/esm/components/StorageManager/hooks/useStorageManager/types.mjs +0 -13
  35. package/dist/esm/components/StorageManager/hooks/useStorageManager/useStorageManager.mjs +0 -62
  36. package/dist/esm/components/StorageManager/hooks/useUploadFiles/useUploadFiles.mjs +0 -79
  37. package/dist/esm/components/StorageManager/types.mjs +0 -11
  38. package/dist/esm/components/StorageManager/utils/checkMaxFileSize.mjs +0 -12
  39. package/dist/esm/components/StorageManager/utils/displayText.mjs +0 -39
  40. package/dist/esm/components/StorageManager/utils/filterAllowedFiles.mjs +0 -27
  41. package/dist/esm/components/StorageManager/utils/getInput.mjs +0 -39
  42. package/dist/esm/components/StorageManager/utils/resolveFile.mjs +0 -20
  43. package/dist/esm/components/StorageManager/utils/uploadFile.mjs +0 -26
  44. package/dist/types/components/StorageManager/hooks/index.d.ts +0 -2
  45. package/dist/types/components/StorageManager/hooks/useStorageManager/actions.d.ts +0 -22
  46. package/dist/types/components/StorageManager/hooks/useStorageManager/index.d.ts +0 -1
  47. package/dist/types/components/StorageManager/hooks/useStorageManager/reducer.d.ts +0 -2
  48. package/dist/types/components/StorageManager/hooks/useStorageManager/types.d.ts +0 -50
  49. package/dist/types/components/StorageManager/hooks/useStorageManager/useStorageManager.d.ts +0 -35
  50. package/dist/types/components/StorageManager/hooks/useUploadFiles/index.d.ts +0 -1
  51. package/dist/types/components/StorageManager/hooks/useUploadFiles/useUploadFiles.d.ts +0 -12
  52. package/dist/types/components/StorageManager/utils/checkMaxFileSize.d.ts +0 -5
  53. package/dist/types/components/StorageManager/utils/displayText.d.ts +0 -22
  54. package/dist/types/components/StorageManager/utils/filterAllowedFiles.d.ts +0 -1
  55. package/dist/types/components/StorageManager/utils/getInput.d.ts +0 -17
  56. package/dist/types/components/StorageManager/utils/index.d.ts +0 -5
  57. package/dist/types/components/StorageManager/utils/resolveFile.d.ts +0 -9
  58. package/dist/types/components/StorageManager/utils/uploadFile.d.ts +0 -32
@@ -1,62 +0,0 @@
1
- import React__default from 'react';
2
- import { isObject } from '@aws-amplify/ui';
3
- import { FileStatus } from '../../types.mjs';
4
- import { storageManagerStateReducer } from './reducer.mjs';
5
- import { addFilesAction, clearFilesAction, queueFilesAction, setUploadingFileAction, setProcessedKeyAction, setUploadProgressAction, setUploadStatusAction, removeUploadAction } from './actions.mjs';
6
-
7
- const isDefaultFile = (file) => !!(isObject(file) && file.key);
8
- const createFileFromDefault = (file) => isDefaultFile(file)
9
- ? { ...file, id: file.key, status: FileStatus.UPLOADED }
10
- : undefined;
11
- function useStorageManager(defaultFiles = []) {
12
- const [{ files }, dispatch] = React__default.useReducer(storageManagerStateReducer, {
13
- files: (Array.isArray(defaultFiles)
14
- ? defaultFiles.map(createFileFromDefault).filter((file) => !!file)
15
- : []),
16
- });
17
- const addFiles = ({ files, status, getFileErrorMessage, }) => {
18
- dispatch(addFilesAction({ files, status, getFileErrorMessage }));
19
- };
20
- const clearFiles = () => {
21
- dispatch(clearFilesAction());
22
- };
23
- const queueFiles = () => {
24
- dispatch(queueFilesAction());
25
- };
26
- const setUploadingFile = ({ uploadTask, id, }) => {
27
- dispatch(setUploadingFileAction({ id, uploadTask }));
28
- };
29
- const setProcessedKey = (input) => {
30
- dispatch(setProcessedKeyAction(input));
31
- };
32
- const setUploadProgress = ({ progress, id, }) => {
33
- dispatch(setUploadProgressAction({ id, progress }));
34
- };
35
- const setUploadSuccess = ({ id }) => {
36
- dispatch(setUploadStatusAction({ id, status: FileStatus.UPLOADED }));
37
- };
38
- const setUploadPaused = ({ id }) => {
39
- dispatch(setUploadStatusAction({ id, status: FileStatus.PAUSED }));
40
- };
41
- const setUploadResumed = ({ id }) => {
42
- dispatch(setUploadStatusAction({ id, status: FileStatus.UPLOADING }));
43
- };
44
- const removeUpload = ({ id }) => {
45
- dispatch(removeUploadAction({ id }));
46
- };
47
- return {
48
- removeUpload,
49
- setProcessedKey,
50
- setUploadPaused,
51
- setUploadProgress,
52
- setUploadResumed,
53
- setUploadSuccess,
54
- setUploadingFile,
55
- queueFiles,
56
- addFiles,
57
- clearFiles,
58
- files,
59
- };
60
- }
61
-
62
- export { useStorageManager };
@@ -1,79 +0,0 @@
1
- import * as React from 'react';
2
- import { isFunction } from '@aws-amplify/ui';
3
- import { getInput } from '../../utils/getInput.mjs';
4
- import { uploadFile } from '../../utils/uploadFile.mjs';
5
- import { FileStatus } from '../../types.mjs';
6
-
7
- function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }) {
8
- React.useEffect(() => {
9
- const filesReadyToUpload = files.filter((file) => file.status === FileStatus.QUEUED);
10
- if (filesReadyToUpload.length > maxFileCount) {
11
- return;
12
- }
13
- for (const { file, key, id } of filesReadyToUpload) {
14
- const onProgress = (event) => {
15
- /**
16
- * When a file is zero bytes, the progress.total will equal zero.
17
- * Therefore, this will prevent a divide by zero error.
18
- */
19
- const progress = event.totalBytes === undefined || event.totalBytes === 0
20
- ? 100
21
- : Math.floor((event.transferredBytes / event.totalBytes) * 100);
22
- setUploadProgress({ id, progress });
23
- };
24
- if (file) {
25
- const handleProcessFileSuccess = (input) => onProcessFileSuccess({ id, ...input });
26
- const input = getInput({
27
- accessLevel,
28
- file,
29
- key,
30
- onProcessFileSuccess: handleProcessFileSuccess,
31
- onProgress,
32
- path,
33
- processFile,
34
- useAccelerateEndpoint,
35
- });
36
- uploadFile({
37
- input,
38
- onComplete: (event) => {
39
- if (isFunction(onUploadSuccess)) {
40
- onUploadSuccess({
41
- key: event.key ??
42
- event.path,
43
- });
44
- }
45
- setUploadSuccess({ id });
46
- },
47
- onError: ({ key, error }) => {
48
- if (isFunction(onUploadError)) {
49
- onUploadError(error.message, { key });
50
- }
51
- },
52
- onStart: ({ key, uploadTask }) => {
53
- if (isFunction(onUploadStart)) {
54
- onUploadStart({ key });
55
- }
56
- setUploadingFile({ id, uploadTask });
57
- },
58
- });
59
- }
60
- }
61
- }, [
62
- files,
63
- accessLevel,
64
- isResumable,
65
- setUploadProgress,
66
- setUploadingFile,
67
- onUploadError,
68
- onProcessFileSuccess,
69
- onUploadSuccess,
70
- onUploadStart,
71
- maxFileCount,
72
- setUploadSuccess,
73
- processFile,
74
- path,
75
- useAccelerateEndpoint,
76
- ]);
77
- }
78
-
79
- export { useUploadFiles };
@@ -1,11 +0,0 @@
1
- var FileStatus;
2
- (function (FileStatus) {
3
- FileStatus["ADDED"] = "added";
4
- FileStatus["QUEUED"] = "queued";
5
- FileStatus["UPLOADING"] = "uploading";
6
- FileStatus["PAUSED"] = "paused";
7
- FileStatus["ERROR"] = "error";
8
- FileStatus["UPLOADED"] = "uploaded";
9
- })(FileStatus || (FileStatus = {}));
10
-
11
- export { FileStatus };
@@ -1,12 +0,0 @@
1
- import { humanFileSize } from '@aws-amplify/ui';
2
-
3
- const checkMaxFileSize = ({ file, getFileSizeErrorText, maxFileSize, }) => {
4
- if (maxFileSize === undefined)
5
- return '';
6
- if (file.size > maxFileSize) {
7
- return getFileSizeErrorText(humanFileSize(maxFileSize, true));
8
- }
9
- return '';
10
- };
11
-
12
- export { checkMaxFileSize };
@@ -1,39 +0,0 @@
1
- const defaultStorageManagerDisplayText = {
2
- getFilesUploadedText(count) {
3
- return `${count} ${count === 1 ? 'file uploaded' : 'files uploaded'}`;
4
- },
5
- getFileSizeErrorText(sizeText) {
6
- return `File size must be below ${sizeText}`;
7
- },
8
- getRemainingFilesText(count) {
9
- return `${count} ${count === 1 ? 'file' : 'files'} uploading`;
10
- },
11
- getSelectedFilesText(count) {
12
- return `${count} ${count === 1 ? 'file' : 'files'} selected`;
13
- },
14
- getUploadingText(percentage) {
15
- return `Uploading${percentage > 0 ? `: ${percentage}%` : ''}`;
16
- },
17
- getUploadButtonText(count) {
18
- return `Upload ${count} ${count === 1 ? 'file' : 'files'}`;
19
- },
20
- getMaxFilesErrorText(count) {
21
- return `Cannot choose more than ${count} ${count === 1 ? 'file' : 'files'}. Remove files before updating`;
22
- },
23
- getErrorText(message) {
24
- return message;
25
- },
26
- doneButtonText: 'Done',
27
- clearAllButtonText: 'Clear all',
28
- extensionNotAllowedText: 'Extension not allowed',
29
- browseFilesText: 'Browse files',
30
- dropFilesText: 'Drop files here or',
31
- pauseButtonText: 'Pause',
32
- resumeButtonText: 'Resume',
33
- uploadSuccessfulText: 'Uploaded',
34
- getPausedText(percentage) {
35
- return `Paused: ${percentage}%`;
36
- },
37
- };
38
-
39
- export { defaultStorageManagerDisplayText };
@@ -1,27 +0,0 @@
1
- const filterAllowedFiles = (files, acceptedFileTypes) => {
2
- // Allow any files if acceptedFileTypes is undefined, empty array, or contains '*'
3
- if (!acceptedFileTypes ||
4
- acceptedFileTypes.length === 0 ||
5
- acceptedFileTypes.includes('*')) {
6
- return files;
7
- }
8
- // Remove any files that are not in the accepted file list
9
- return files.filter((file) => {
10
- const fileName = file.name || '';
11
- const mimeType = (file.type || '').toLowerCase();
12
- const baseMimeType = mimeType.replace(/\/.*$/, '');
13
- return acceptedFileTypes.some((type) => {
14
- const validType = type.trim().toLowerCase();
15
- if (validType.charAt(0) === '.') {
16
- return fileName.toLowerCase().endsWith(validType);
17
- }
18
- else if (validType.endsWith('/*')) {
19
- // This is something like a image/* mime type
20
- return baseMimeType === validType.replace(/\/.*$/, '');
21
- }
22
- return mimeType === validType;
23
- });
24
- });
25
- };
26
-
27
- export { filterAllowedFiles };
@@ -1,39 +0,0 @@
1
- import { fetchAuthSession } from 'aws-amplify/auth';
2
- import { isTypedFunction, isString } from '@aws-amplify/ui';
3
- import { resolveFile } from './resolveFile.mjs';
4
-
5
- const getInput = ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, useAccelerateEndpoint, }) => {
6
- return async () => {
7
- const hasCallbackPath = isTypedFunction(path);
8
- const hasStringPath = isString(path);
9
- const hasKeyInput = !!accessLevel && !hasCallbackPath;
10
- const { file: data, key: processedKey, ...rest } = await resolveFile({ file, key, processFile });
11
- const contentType = file.type || 'binary/octet-stream';
12
- // IMPORTANT: always pass `...rest` here for backwards compatibility
13
- const options = { contentType, onProgress, useAccelerateEndpoint, ...rest };
14
- let inputResult;
15
- if (hasKeyInput) {
16
- // legacy handling of `path` is to prefix to `fileKey`
17
- const resolvedKey = hasStringPath
18
- ? `${path}${processedKey}`
19
- : processedKey;
20
- inputResult = {
21
- data,
22
- key: resolvedKey,
23
- options: { ...options, accessLevel },
24
- };
25
- }
26
- else {
27
- const { identityId } = await fetchAuthSession();
28
- const resolvedPath = `${hasCallbackPath ? path({ identityId }) : path}${processedKey}`;
29
- inputResult = { data: file, path: resolvedPath, options };
30
- }
31
- if (processFile) {
32
- // provide post-processing value of target `key`
33
- onProcessFileSuccess({ processedKey });
34
- }
35
- return inputResult;
36
- };
37
- };
38
-
39
- export { getInput };
@@ -1,20 +0,0 @@
1
- import { isFunction } from '@aws-amplify/ui';
2
-
3
- /**
4
- * Utility function that takes the processFile prop, along with a file a key
5
- * and returns a Promise that resolves to { file, key, ..rest }
6
- * regardless if processFile is defined and if it is sync or async
7
- */
8
- const resolveFile = ({ processFile, ...input }) => {
9
- return new Promise((resolve, reject) => {
10
- const result = isFunction(processFile) ? processFile(input) : input;
11
- if (result instanceof Promise) {
12
- result.then(resolve).catch(reject);
13
- }
14
- else {
15
- resolve(result);
16
- }
17
- });
18
- };
19
-
20
- export { resolveFile };
@@ -1,26 +0,0 @@
1
- import { uploadData } from 'aws-amplify/storage';
2
- import { isFunction } from '@aws-amplify/ui';
3
-
4
- async function uploadFile({ input, onError, onStart, onComplete, }) {
5
- const resolvedInput = await input();
6
- const uploadTask = uploadData(resolvedInput);
7
- const key = resolvedInput?.key ??
8
- resolvedInput?.path;
9
- if (isFunction(onStart)) {
10
- onStart({ key, uploadTask });
11
- }
12
- uploadTask.result
13
- .then((result) => {
14
- if (isFunction(onComplete) && uploadTask.state === 'SUCCESS') {
15
- onComplete(result);
16
- }
17
- })
18
- .catch((error) => {
19
- if (isFunction(onError)) {
20
- onError({ key, error });
21
- }
22
- });
23
- return uploadTask;
24
- }
25
-
26
- export { uploadFile };
@@ -1,2 +0,0 @@
1
- export { useStorageManager, UseStorageManager } from './useStorageManager';
2
- export { useUploadFiles } from './useUploadFiles';
@@ -1,22 +0,0 @@
1
- import { FileStatus } from '../../types';
2
- import { Action, AddFilesActionParams } from './types';
3
- import { TaskEvent } from '../../utils';
4
- export declare const addFilesAction: ({ files, status, getFileErrorMessage, }: AddFilesActionParams) => Action;
5
- export declare const clearFilesAction: () => Action;
6
- export declare const queueFilesAction: () => Action;
7
- export declare const setProcessedKeyAction: (input: {
8
- id: string;
9
- processedKey: string;
10
- }) => Action;
11
- export declare const setUploadingFileAction: ({ id, uploadTask, }: TaskEvent) => Action;
12
- export declare const setUploadProgressAction: ({ id, progress, }: {
13
- id: string;
14
- progress: number;
15
- }) => Action;
16
- export declare const setUploadStatusAction: ({ id, status, }: {
17
- id: string;
18
- status: FileStatus;
19
- }) => Action;
20
- export declare const removeUploadAction: ({ id }: {
21
- id: string;
22
- }) => Action;
@@ -1 +0,0 @@
1
- export { useStorageManager, UseStorageManager } from './useStorageManager';
@@ -1,2 +0,0 @@
1
- import { Action, UseStorageManagerState } from './types';
2
- export declare function storageManagerStateReducer(state: UseStorageManagerState, action: Action): UseStorageManagerState;
@@ -1,50 +0,0 @@
1
- import { FileStatus, StorageFiles } from '../../types';
2
- import { UploadTask } from '../../utils';
3
- export interface UseStorageManagerState {
4
- files: StorageFiles;
5
- }
6
- export declare enum StorageManagerActionTypes {
7
- ADD_FILES = "ADD_FILES",
8
- CLEAR_FILES = "CLEAR_FILES",
9
- QUEUE_FILES = "QUEUE_FILES",
10
- SET_STATUS = "SET_STATUS",
11
- SET_PROCESSED_FILE_KEY = "SET_PROCESSED_FILE_KEY",
12
- SET_STATUS_UPLOADING = "SET_STATUS_UPLOADING",
13
- SET_UPLOAD_PROGRESS = "SET_UPLOAD_PROGRESS",
14
- REMOVE_UPLOAD = "REMOVE_UPLOAD"
15
- }
16
- export type GetFileErrorMessage = (file: File) => string;
17
- export type Action = {
18
- type: StorageManagerActionTypes.ADD_FILES;
19
- files: File[];
20
- status: FileStatus;
21
- getFileErrorMessage: GetFileErrorMessage;
22
- } | {
23
- type: StorageManagerActionTypes.CLEAR_FILES;
24
- } | {
25
- type: StorageManagerActionTypes.SET_STATUS;
26
- id: string;
27
- status: FileStatus;
28
- } | {
29
- type: StorageManagerActionTypes.QUEUE_FILES;
30
- } | {
31
- type: StorageManagerActionTypes.SET_STATUS_UPLOADING;
32
- id: string;
33
- uploadTask?: UploadTask;
34
- } | {
35
- type: StorageManagerActionTypes.SET_UPLOAD_PROGRESS;
36
- id: string;
37
- progress: number;
38
- } | {
39
- type: StorageManagerActionTypes.SET_PROCESSED_FILE_KEY;
40
- id: string;
41
- processedKey: string;
42
- } | {
43
- type: StorageManagerActionTypes.REMOVE_UPLOAD;
44
- id: string;
45
- };
46
- export interface AddFilesActionParams {
47
- files: File[];
48
- status: FileStatus;
49
- getFileErrorMessage: GetFileErrorMessage;
50
- }
@@ -1,35 +0,0 @@
1
- import { StorageFiles, FileStatus, DefaultFile } from '../../types';
2
- import { GetFileErrorMessage } from './types';
3
- import { TaskHandler } from '../../utils';
4
- export interface UseStorageManager {
5
- addFiles: (params: {
6
- files: File[];
7
- status: FileStatus;
8
- getFileErrorMessage: GetFileErrorMessage;
9
- }) => void;
10
- clearFiles: () => void;
11
- queueFiles: () => void;
12
- setUploadingFile: TaskHandler;
13
- setProcessedKey: (params: {
14
- id: string;
15
- processedKey: string;
16
- }) => void;
17
- setUploadProgress: (params: {
18
- id: string;
19
- progress: number;
20
- }) => void;
21
- setUploadSuccess: (params: {
22
- id: string;
23
- }) => void;
24
- setUploadResumed: (params: {
25
- id: string;
26
- }) => void;
27
- setUploadPaused: (params: {
28
- id: string;
29
- }) => void;
30
- removeUpload: (params: {
31
- id: string;
32
- }) => void;
33
- files: StorageFiles;
34
- }
35
- export declare function useStorageManager(defaultFiles?: Array<DefaultFile>): UseStorageManager;
@@ -1 +0,0 @@
1
- export { useUploadFiles, UseUploadFilesProps } from './useUploadFiles';
@@ -1,12 +0,0 @@
1
- import { PathCallback } from '../../utils';
2
- import { StorageManagerProps } from '../../types';
3
- import { UseStorageManager } from '../useStorageManager';
4
- export interface UseUploadFilesProps extends Pick<StorageManagerProps, 'isResumable' | 'onUploadSuccess' | 'onUploadError' | 'onUploadStart' | 'maxFileCount' | 'processFile' | 'useAccelerateEndpoint'>, Pick<UseStorageManager, 'setUploadingFile' | 'setUploadProgress' | 'setUploadSuccess' | 'files'> {
5
- accessLevel?: StorageManagerProps['accessLevel'];
6
- onProcessFileSuccess: (input: {
7
- id: string;
8
- processedKey: string;
9
- }) => void;
10
- path?: string | PathCallback;
11
- }
12
- export declare function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }: UseUploadFilesProps): void;
@@ -1,5 +0,0 @@
1
- export declare const checkMaxFileSize: ({ file, getFileSizeErrorText, maxFileSize, }: {
2
- file: File;
3
- getFileSizeErrorText: (sizeText: string) => string;
4
- maxFileSize?: number | undefined;
5
- }) => string;
@@ -1,22 +0,0 @@
1
- import { DisplayTextTemplate } from '@aws-amplify/ui';
2
- export type StorageManagerDisplayText = DisplayTextTemplate<{
3
- getFilesUploadedText?: (count: number) => string;
4
- getFileSizeErrorText?: (sizeText: string) => string;
5
- getRemainingFilesText?: (count: number) => string;
6
- getSelectedFilesText?: (count: number) => string;
7
- getUploadingText?: (percentage: number) => string;
8
- getUploadButtonText?: (count: number) => string;
9
- getMaxFilesErrorText?: (count: number) => string;
10
- getErrorText?: (message: string) => string;
11
- doneButtonText?: string;
12
- clearAllButtonText?: string;
13
- extensionNotAllowedText?: string;
14
- browseFilesText?: string;
15
- dropFilesText?: string;
16
- pauseButtonText?: string;
17
- resumeButtonText?: string;
18
- uploadSuccessfulText?: string;
19
- getPausedText?: (percentage: number) => string;
20
- }>;
21
- export type StorageManagerDisplayTextDefault = Required<StorageManagerDisplayText>;
22
- export declare const defaultStorageManagerDisplayText: StorageManagerDisplayTextDefault;
@@ -1 +0,0 @@
1
- export declare const filterAllowedFiles: (files: File[], acceptedFileTypes?: string[]) => File[];
@@ -1,17 +0,0 @@
1
- import { StorageAccessLevel } from '@aws-amplify/core';
2
- import { UploadDataWithPathInput, UploadDataInput } from 'aws-amplify/storage';
3
- import { ProcessFile } from '../types';
4
- import { PathCallback, PathInput } from './uploadFile';
5
- export interface GetInputParams {
6
- accessLevel: StorageAccessLevel | undefined;
7
- file: File;
8
- key: string;
9
- onProcessFileSuccess: (input: {
10
- processedKey: string;
11
- }) => void;
12
- onProgress: NonNullable<UploadDataWithPathInput['options']>['onProgress'];
13
- path: string | PathCallback | undefined;
14
- processFile: ProcessFile | undefined;
15
- useAccelerateEndpoint?: boolean;
16
- }
17
- export declare const getInput: ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, useAccelerateEndpoint, }: GetInputParams) => () => Promise<PathInput | UploadDataInput>;
@@ -1,5 +0,0 @@
1
- export { checkMaxFileSize } from './checkMaxFileSize';
2
- export { defaultStorageManagerDisplayText, StorageManagerDisplayText, StorageManagerDisplayTextDefault, } from './displayText';
3
- export { filterAllowedFiles } from './filterAllowedFiles';
4
- export { getInput } from './getInput';
5
- export { PathCallback, TaskEvent, TaskHandler, uploadFile, UploadTask, } from './uploadFile';
@@ -1,9 +0,0 @@
1
- import { ProcessFile, ProcessFileParams } from '../types';
2
- /**
3
- * Utility function that takes the processFile prop, along with a file a key
4
- * and returns a Promise that resolves to { file, key, ..rest }
5
- * regardless if processFile is defined and if it is sync or async
6
- */
7
- export declare const resolveFile: ({ processFile, ...input }: ProcessFileParams & {
8
- processFile?: ProcessFile | undefined;
9
- }) => Promise<ProcessFileParams>;
@@ -1,32 +0,0 @@
1
- import { UploadDataInput, UploadDataWithPathOutput, UploadDataWithPathInput, UploadDataOutput } from 'aws-amplify/storage';
2
- /**
3
- * Callback provided an input containing the current `identityId`
4
- *
5
- * @param {{identityId: string | undefined}} input - Input parameters
6
- * @returns target S3 bucket key
7
- */
8
- export type PathCallback = (input: {
9
- identityId: string | undefined;
10
- }) => string;
11
- export type UploadTask = UploadDataOutput | UploadDataWithPathOutput;
12
- export interface TaskEvent {
13
- id: string;
14
- uploadTask: UploadTask;
15
- }
16
- export type PathInput = Omit<UploadDataWithPathInput, 'path'> & {
17
- path: string;
18
- };
19
- export type TaskHandler = (event: TaskEvent) => void;
20
- export interface UploadFileProps {
21
- input: () => Promise<PathInput | UploadDataInput>;
22
- onComplete?: (result: Awaited<(UploadDataWithPathOutput | UploadDataOutput)['result']>) => void;
23
- onError?: (event: {
24
- key: string;
25
- error: Error;
26
- }) => void;
27
- onStart?: (event: {
28
- key: string;
29
- uploadTask: UploadTask;
30
- }) => void;
31
- }
32
- export declare function uploadFile({ input, onError, onStart, onComplete, }: UploadFileProps): Promise<UploadDataWithPathOutput | UploadDataOutput>;