Skip to content

Commit

Permalink
fix(react-storage): enable default checksum algorithm for create fold…
Browse files Browse the repository at this point in the history
…er action (#6305)

* fix: include default checksum alg header in createFolder action

* test: update createFolder test spec for checksum alg header

* chore: adding changeset
  • Loading branch information
jjarvisp authored Jan 18, 2025
1 parent 6e51c17 commit ac50ec3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/large-swans-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@aws-amplify/ui-react-storage': patch
---

fix(react-storage): enable default checksum algorithm for create folder action #6305

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createFolderHandler, CreateFolderHandlerInput } from '../createFolder';

import { uploadData, UploadDataInput } from '../../../storage-internal';
import { DEFAULT_CHECKSUM_ALGORITHM } from '../constants';

jest.mock('../../../storage-internal');

Expand Down Expand Up @@ -70,6 +71,7 @@ describe('createFolderHandler', () => {
locationCredentialsProvider: credentials,
onProgress: expect.any(Function),
preventOverwrite: true,
checksumAlgorithm: DEFAULT_CHECKSUM_ALGORITHM,
},
path: baseInput.data.key,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DEFAULT_CHECKSUM_ALGORITHM = 'crc-32';
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TaskHandlerOptions,
} from './types';
import { constructBucket, getProgress } from './utils';
import { DEFAULT_CHECKSUM_ALGORITHM } from './constants';

export interface CreateFolderHandlerData extends TaskData {
preventOverwrite?: boolean;
Expand Down Expand Up @@ -48,6 +49,7 @@ export const createFolderHandler: CreateFolderHandler = (input) => {
if (isFunction(onProgress)) onProgress(data, getProgress(event));
},
preventOverwrite,
checksumAlgorithm: DEFAULT_CHECKSUM_ALGORITHM,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from './types';

import { constructBucket, getProgress } from './utils';
import { DEFAULT_CHECKSUM_ALGORITHM } from './constants';

export interface UploadHandlerOptions
extends TaskHandlerOptions<{ key: string }> {}
Expand All @@ -34,8 +35,6 @@ export interface UploadHandler
// https://github.com/aws-amplify/amplify-js/blob/1a5366d113c9af4ce994168653df3aadb142c581/packages/storage/src/providers/s3/utils/constants.ts#L16
export const MULTIPART_UPLOAD_THRESHOLD_BYTES = 5 * 1024 * 1024;

export const DEFAULT_CHECKSUM_ALGORITHM = 'crc-32';

export const UNDEFINED_CALLBACKS = {
cancel: undefined,
pause: undefined,
Expand Down

0 comments on commit ac50ec3

Please sign in to comment.