Skip to content

Commit

Permalink
fix(storage): assertion for maxUrlExpiration in getUrl api (#11981)
Browse files Browse the repository at this point in the history
fix(storage): assertion for maxUrlExpiration

Co-authored-by: AllanZhengYP <[email protected]>
  • Loading branch information
Venkata Ramyasri Kota and AllanZhengYP authored Sep 6, 2023
1 parent 65f21cb commit 2af0ca0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/storage/src/providers/s3/apis/internal/getUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import { getPresignedGetObjectUrl } from '../../utils/client';
import { getProperties } from './getProperties';
import { resolveS3ConfigAndInput } from '../../utils';
import { assertValidationError } from '../../../../errors/utils/assertValidationError';

const DEFAULT_PRESIGN_EXPIRATION = 900;
const MAX_URL_EXPIRATION = 7 * 24 * 60 * 60 * 1000;
import {
DEFAULT_PRESIGN_EXPIRATION,
MAX_URL_EXPIRATION,
} from '../../utils/constants';

export const getUrl = async function (
amplify: AmplifyClassV6,
Expand All @@ -37,9 +38,9 @@ export const getUrl = async function (
);
urlExpirationInSec = Math.min(awsCredExpirationInSec, urlExpirationInSec);
}

const maxUrlExpirationInSec = MAX_URL_EXPIRATION / 1000;
assertValidationError(
urlExpirationInSec < MAX_URL_EXPIRATION,
urlExpirationInSec <= maxUrlExpirationInSec,
StorageValidationErrorCode.UrlExpirationMaxLimitExceed
);

Expand Down

0 comments on commit 2af0ca0

Please sign in to comment.