-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storage): add path supp to copy API
- Loading branch information
Ashwin Kumar
committed
Mar 12, 2024
1 parent
32990ee
commit 511e83c
Showing
14 changed files
with
338 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,46 @@ | |
|
||
import { Amplify } from '@aws-amplify/core'; | ||
|
||
import { CopyInput, CopyOutput, S3Exception } from '../types'; | ||
import { | ||
CopyInput, | ||
CopyInputKey, | ||
Check warning on line 8 in packages/storage/src/providers/s3/apis/copy.ts
|
||
CopyInputPath, | ||
CopyOutput, | ||
CopyOutputKey, | ||
Check warning on line 11 in packages/storage/src/providers/s3/apis/copy.ts
|
||
CopyOutputPath, | ||
S3Exception, | ||
} from '../types'; | ||
import { StorageValidationErrorCode } from '../../../errors/types/validation'; | ||
|
||
import { copy as copyInternal } from './internal/copy'; | ||
|
||
/** | ||
* Copy an object from a source object to a new object within the same bucket. Can optionally copy files across | ||
* different level or identityId (if source object's level is 'protected'). | ||
* | ||
* @param input - The CopyInput object. | ||
* @returns Output containing the destination key. | ||
* @throws service: {@link S3Exception} - Thrown when checking for existence of the object | ||
* @throws validation: {@link StorageValidationErrorCode } - Thrown when | ||
* source or destination key are not defined. | ||
*/ | ||
export const copy = async (input: CopyInput): Promise<CopyOutput> => { | ||
return copyInternal(Amplify, input); | ||
}; | ||
interface Copy { | ||
/** | ||
* Copy an object from a source object to a new object within the same bucket. | ||
* | ||
* @param input - The CopyInputPath object. | ||
* @returns Output containing the destination object path. | ||
* @throws service: {@link S3Exception} - Thrown when checking for existence of the object | ||
* @throws validation: {@link StorageValidationErrorCode } - Thrown when | ||
* source or destination path is not defined. | ||
*/ | ||
(input: CopyInputPath): Promise<CopyOutputPath>; | ||
/** | ||
* @deprecated The `key` and `accessLevel` parameters are deprecated and will be removed in next major version. | ||
* Please use {@link https://docs.amplify.aws/react/build-a-backend/storage/copy | path} instead. | ||
* | ||
* Copy an object from a source object to a new object within the same bucket. Can optionally copy files across | ||
* different level or identityId (if source object's level is 'protected'). | ||
* | ||
* @param input - The CopyInputKey object. | ||
* @returns Output containing the destination object key. | ||
* @throws service: {@link S3Exception} - Thrown when checking for existence of the object | ||
* @throws validation: {@link StorageValidationErrorCode } - Thrown when | ||
* source or destination key is not defined. | ||
*/ | ||
(input: CopyInputKey): Promise<CopyOutputKey>; | ||
Check warning on line 43 in packages/storage/src/providers/s3/apis/copy.ts
|
||
} | ||
|
||
export const copy: Copy = <Output extends CopyOutput>( | ||
input: CopyInput, | ||
): Promise<Output> => copyInternal(Amplify, input) as Promise<Output>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.