UNPKG

4.1 kBTypeScriptView Raw
1import { PutObjectCommandInput } from '@aws-sdk/client-s3';
2import { StorageOptions, StorageProvider, S3ProviderGetConfig, S3ProviderGetOuput, S3ProviderPutConfig, S3ProviderRemoveConfig, S3ProviderListOutput, S3ProviderListConfig, S3ProviderPutOutput, S3ProviderCopyConfig, S3ProviderCopyOutput, S3CopySource, S3CopyDestination, S3ProviderRemoveOutput } from '../types';
3/**
4 * Provide storage methods to use AWS S3
5 */
6export declare class AWSS3Provider implements StorageProvider {
7 static readonly CATEGORY = "Storage";
8 static readonly PROVIDER_NAME = "AWSS3";
9 private _config;
10 /**
11 * Initialize Storage with AWS configurations
12 * @param {Object} config - Configuration object for storage
13 */
14 constructor(config?: StorageOptions);
15 /**
16 * get the category of the plugin
17 */
18 getCategory(): string;
19 /**
20 * get provider name of the plugin
21 */
22 getProviderName(): string;
23 /**
24 * Configure Storage part with aws configuration
25 * @param {Object} config - Configuration of the Storage
26 * @return {Object} - Current configuration
27 */
28 configure(config?: any): object;
29 /**
30 * Copy an object from a source object to a new object within the same bucket. Can optionally copy files across
31 * different level or identityId (if source object's level is 'protected').
32 *
33 * @async
34 * @param {S3CopySource} src - Key and optionally access level and identityId of the source object.
35 * @param {S3CopyDestination} dest - Key and optionally access level of the destination object.
36 * @param {S3ProviderCopyConfig} [config] - Optional configuration for s3 commands.
37 * @return {Promise<S3ProviderCopyOutput>} The key of the copied object.
38 */
39 copy(src: S3CopySource, dest: S3CopyDestination, config?: S3ProviderCopyConfig): Promise<S3ProviderCopyOutput>;
40 /**
41 * Get a presigned URL of the file or the object data when download:true
42 *
43 * @param {string} key - key of the object
44 * @param {S3ProviderGetConfig} [config] - Optional configuration for the underlying S3 command
45 * @return {Promise<string | GetObjectCommandOutput>} - A promise resolves to Amazon S3 presigned URL or the
46 * GetObjectCommandOutput if download is set to true on success
47 */
48 get<T extends S3ProviderGetConfig & StorageOptions>(key: string, config?: T): Promise<S3ProviderGetOuput<T>>;
49 /**
50 * Put a file in S3 bucket specified to configure method
51 * @param {string} key - key of the object
52 * @param {PutObjectCommandInput["Body"]} object - File to be put in Amazon S3 bucket
53 * @param {S3ProviderPutConfig} [config] - Optional configuration for the underlying S3 command
54 * @return {Promise<S3ProviderPutOutput>} - promise resolves to an object with the new object's key on success
55 */
56 put(key: string, object: PutObjectCommandInput['Body'], config?: S3ProviderPutConfig): Promise<S3ProviderPutOutput>;
57 /**
58 * Remove the object for specified key
59 * @param {string} key - key of the object
60 * @param {S3ProviderRemoveConfig} [config] - Optional configuration for the underlying S3 command
61 * @return {Promise<S3ProviderRemoveOutput>} - Promise resolves upon successful removal of the object
62 */
63 remove(key: string, config?: S3ProviderRemoveConfig): Promise<S3ProviderRemoveOutput>;
64 /**
65 * List bucket objects relative to the level and prefix specified
66 * @param {string} path - the path that contains objects
67 * @param {S3ProviderListConfig} [config] - Optional configuration for the underlying S3 command
68 * @return {Promise<S3ProviderListOutput>} - Promise resolves to list of keys, eTags, lastModified and file size for
69 * all objects in path
70 */
71 list(path: string, config?: S3ProviderListConfig): Promise<S3ProviderListOutput>;
72 private _ensureCredentials;
73 private _isWithCredentials;
74 private _prefix;
75 /**
76 * Creates an S3 client with new V3 aws sdk
77 */
78 private _createNewS3Client;
79}
80/**
81 * @deprecated use named import
82 */
83export default AWSS3Provider;