UNPKG

5.18 kBTypeScriptView Raw
1import { GetObjectRequest, GetObjectCommandOutput, PutObjectRequest, CopyObjectRequest, _Object, DeleteObjectCommandOutput } from '@aws-sdk/client-s3';
2import { StorageOptions, StorageAccessLevel } from './Storage';
3import { UploadTaskCompleteEvent, UploadTaskProgressEvent } from '../providers/AWSS3UploadTask';
4import { UploadTask } from './Provider';
5import { ICredentials } from '@aws-amplify/core';
6declare type ListObjectsCommandOutputContent = _Object;
7export interface FileMetadata {
8 bucket: string;
9 fileName: string;
10 key: string;
11 lastTouched: number;
12 uploadId: string;
13}
14export declare type CommonStorageOptions = Omit<StorageOptions, 'credentials' | 'region' | 'bucket' | 'dangerouslyConnectToHttpEndpointForTesting'>;
15export declare type S3ProviderGetConfig = CommonStorageOptions & {
16 download?: boolean;
17 track?: boolean;
18 expires?: number;
19 provider?: 'AWSS3';
20 identityId?: string;
21 progressCallback?: (progress: any) => any;
22 cacheControl?: GetObjectRequest['ResponseCacheControl'];
23 contentDisposition?: GetObjectRequest['ResponseContentDisposition'];
24 contentEncoding?: GetObjectRequest['ResponseContentEncoding'];
25 contentLanguage?: GetObjectRequest['ResponseContentLanguage'];
26 contentType?: GetObjectRequest['ResponseContentType'];
27 SSECustomerAlgorithm?: GetObjectRequest['SSECustomerAlgorithm'];
28 SSECustomerKey?: GetObjectRequest['SSECustomerKey'];
29 SSECustomerKeyMD5?: GetObjectRequest['SSECustomerKeyMD5'];
30};
31export declare type S3ProviderGetOuput<T> = T extends {
32 download: true;
33} ? GetObjectCommandOutput : string;
34declare type _S3ProviderPutConfig = {
35 progressCallback?: (progress: any) => any;
36 provider?: 'AWSS3';
37 track?: boolean;
38 serverSideEncryption?: PutObjectRequest['ServerSideEncryption'];
39 SSECustomerAlgorithm?: PutObjectRequest['SSECustomerAlgorithm'];
40 SSECustomerKey?: PutObjectRequest['SSECustomerKey'];
41 SSECustomerKeyMD5?: PutObjectRequest['SSECustomerKeyMD5'];
42 SSEKMSKeyId?: PutObjectRequest['SSEKMSKeyId'];
43 acl?: PutObjectRequest['ACL'];
44 bucket?: PutObjectRequest['Bucket'];
45 cacheControl?: PutObjectRequest['CacheControl'];
46 contentDisposition?: PutObjectRequest['ContentDisposition'];
47 contentEncoding?: PutObjectRequest['ContentEncoding'];
48 contentType?: PutObjectRequest['ContentType'];
49 expires?: PutObjectRequest['Expires'];
50 metadata?: PutObjectRequest['Metadata'];
51 tagging?: PutObjectRequest['Tagging'];
52 useAccelerateEndpoint?: boolean;
53 resumable?: boolean;
54};
55export declare type ResumableUploadConfig = {
56 resumable: true;
57 progressCallback?: (progress: UploadTaskProgressEvent) => any;
58 completeCallback?: (event: UploadTaskCompleteEvent) => any;
59 errorCallback?: (err: any) => any;
60};
61export declare type S3ProviderPutConfig = CommonStorageOptions & (_S3ProviderPutConfig | (_S3ProviderPutConfig & ResumableUploadConfig));
62export declare type S3ProviderRemoveConfig = CommonStorageOptions & {
63 bucket?: string;
64 provider?: 'AWSS3';
65};
66export declare type S3ProviderListOutput = {
67 results: S3ProviderListOutputItem[];
68 nextToken?: string;
69 hasNextToken: boolean;
70};
71export declare type S3ProviderRemoveOutput = DeleteObjectCommandOutput;
72export declare type S3ProviderListConfig = CommonStorageOptions & {
73 bucket?: string;
74 pageSize?: number | 'ALL';
75 provider?: 'AWSS3';
76 identityId?: string;
77 nextToken?: string;
78};
79export declare type S3ClientOptions = StorageOptions & {
80 credentials: ICredentials;
81} & S3ProviderListConfig;
82export interface S3ProviderListOutputItem {
83 key: ListObjectsCommandOutputContent['Key'];
84 eTag: ListObjectsCommandOutputContent['ETag'];
85 lastModified: ListObjectsCommandOutputContent['LastModified'];
86 size: ListObjectsCommandOutputContent['Size'];
87}
88export interface S3CopyTarget {
89 key: string;
90 level?: StorageAccessLevel;
91 identityId?: string;
92}
93export declare type S3CopySource = S3CopyTarget;
94export declare type S3CopyDestination = Omit<S3CopyTarget, 'identityId'>;
95export declare type S3ProviderCopyConfig = Omit<CommonStorageOptions, 'level'> & {
96 provider?: 'AWSS3';
97 bucket?: CopyObjectRequest['Bucket'];
98 cacheControl?: CopyObjectRequest['CacheControl'];
99 contentDisposition?: CopyObjectRequest['ContentDisposition'];
100 contentLanguage?: CopyObjectRequest['ContentLanguage'];
101 contentType?: CopyObjectRequest['ContentType'];
102 expires?: CopyObjectRequest['Expires'];
103 tagging?: CopyObjectRequest['Tagging'];
104 acl?: CopyObjectRequest['ACL'];
105 metadata?: CopyObjectRequest['Metadata'];
106 serverSideEncryption?: CopyObjectRequest['ServerSideEncryption'];
107 SSECustomerAlgorithm?: CopyObjectRequest['SSECustomerAlgorithm'];
108 SSECustomerKey?: CopyObjectRequest['SSECustomerKey'];
109 SSECustomerKeyMD5?: CopyObjectRequest['SSECustomerKeyMD5'];
110 SSEKMSKeyId?: CopyObjectRequest['SSEKMSKeyId'];
111};
112export declare type S3ProviderCopyOutput = {
113 key: string;
114};
115export declare type PutResult = {
116 key: string;
117};
118export declare type S3ProviderPutOutput<T> = T extends {
119 resumable: true;
120} ? UploadTask : Promise<PutResult>;
121export {};