Skip to content

Commit

Permalink
chore: add overload for deprecation messaging to getUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
erinleigh90 committed Mar 25, 2024
1 parent 3b5a402 commit 30d5b86
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 18 deletions.
65 changes: 47 additions & 18 deletions packages/storage/src/providers/s3/apis/getUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,54 @@

import { Amplify } from '@aws-amplify/core';

import { GetUrlInput, GetUrlOutput } from '../types';
import {
GetUrlInput,
GetUrlInputKey,
GetUrlInputPath,
GetUrlOutput,
} from '../types';

import { getUrl as getUrlInternal } from './internal/getUrl';

/**
* Get a temporary presigned URL to download the specified S3 object.
* The presigned URL expires when the associated role used to sign the request expires or
* the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
*
* By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
* to true, this method will verify the given object already exists in S3 before returning a presigned
* URL, and will throw `StorageError` if the object does not exist.
*
* @param input - The `GetUrlInput` object.
* @returns Presigned URL and timestamp when the URL MAY expire.
* @throws service: `S3Exception` - thrown when checking for existence of the object
* @throws validation: `StorageValidationErrorCode` - Validation errors
* thrown either username or key are not defined.
*
*/
export const getUrl = (input: GetUrlInput): Promise<GetUrlOutput> =>
interface GetUrl {
/**
* Get a temporary presigned URL to download the specified S3 object.
* The presigned URL expires when the associated role used to sign the request expires or
* the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
*
* By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
* to true, this method will verify the given object already exists in S3 before returning a presigned
* URL, and will throw `StorageError` if the object does not exist.
*
* @param input - The `GetUrlInput` object.
* @returns Presigned URL and timestamp when the URL MAY expire.
* @throws service: `S3Exception` - thrown when checking for existence of the object
* @throws validation: `StorageValidationErrorCode` - Validation errors
* thrown either username or key are not defined.
*
*/
(input: GetUrlInputPath): Promise<GetUrlOutput>;
/**
* @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
* Please use {@link https://docs.amplify.aws/javascript/build-a-backend/storage/download/#generate-a-download-url | path} instead.
*
* Get a temporary presigned URL to download the specified S3 object.
* The presigned URL expires when the associated role used to sign the request expires or
* the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
*
* By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
* to true, this method will verify the given object already exists in S3 before returning a presigned
* URL, and will throw `StorageError` if the object does not exist.
*
* @param input - The `GetUrlInput` object.
* @returns Presigned URL and timestamp when the URL MAY expire.
* @throws service: `S3Exception` - thrown when checking for existence of the object
* @throws validation: `StorageValidationErrorCode` - Validation errors
* thrown either username or key are not defined.
*
*/
(input: GetUrlInputKey): Promise<GetUrlOutput>;
}

export const getUrl: GetUrl = (input: GetUrlInput): Promise<GetUrlOutput> =>
getUrlInternal(Amplify, input);
2 changes: 2 additions & 0 deletions packages/storage/src/providers/s3/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export {
GetPropertiesInputKey,
GetPropertiesInputPath,
GetUrlInput,
GetUrlInputKey,
GetUrlInputPath,
ListAllInput,
ListPaginateInput,
RemoveInput,
Expand Down

0 comments on commit 30d5b86

Please sign in to comment.