1 | import { StorageProvider, StorageCopySource, StorageCopyDestination } from './types';
|
2 | /**
|
3 | * Provide storage methods to use AWS S3
|
4 | */
|
5 | export declare class Storage {
|
6 | /**
|
7 | * @private
|
8 | */
|
9 | private _config;
|
10 | private _pluggables;
|
11 | /**
|
12 | * Similar to the API module. This weak map allows users to cancel their in-flight request made using the Storage
|
13 | * module. For every get or put request, a unique cancel token will be generated and injected to it's underlying
|
14 | * AxiosHttpHandler. This map maintains a mapping of Request to CancelTokenSource. When .cancel is invoked, it will
|
15 | * attempt to retrieve it's corresponding cancelTokenSource and cancel the in-flight request.
|
16 | */
|
17 | private _cancelTokenSourceMap;
|
18 | /**
|
19 | * @public
|
20 | */
|
21 | vault: Storage;
|
22 | /**
|
23 | * Initialize Storage
|
24 | * @param {Object} config - Configuration object for storage
|
25 | */
|
26 | constructor();
|
27 | getModuleName(): string;
|
28 | /**
|
29 | * add plugin into Storage category
|
30 | * @param {Object} pluggable - an instance of the plugin
|
31 | */
|
32 | addPluggable(pluggable: StorageProvider): {};
|
33 | /**
|
34 | * Get the plugin object
|
35 | * @param providerName - the name of the plugin
|
36 | */
|
37 | getPluggable(providerName: string): StorageProvider;
|
38 | /**
|
39 | * Remove the plugin object
|
40 | * @param providerName - the name of the plugin
|
41 | */
|
42 | removePluggable(providerName: string): void;
|
43 | /**
|
44 | * Configure Storage
|
45 | * @param {Object} config - Configuration object for storage
|
46 | * @return {Object} - Current configuration
|
47 | */
|
48 | configure(config?: any): any;
|
49 | private getCancellableTokenSource;
|
50 | private updateRequestToBeCancellable;
|
51 | /**
|
52 | * Cancels an inflight request
|
53 | *
|
54 | * @param {Promise<any>} request - The request to cancel
|
55 | * @param {string} [message] - A message to include in the cancelation exception
|
56 | */
|
57 | cancel(request: Promise<any>, message?: string): void;
|
58 | /**
|
59 | * Copies a file from the src key to dest key.
|
60 | *
|
61 | * @param {string} src - key of the source object.
|
62 | * @param {string} dest - key of the destination object.
|
63 | * @param {any} [config] - config.
|
64 | * @return {Promise<any>} - A promise resolves to the copied object's key.
|
65 | */
|
66 | copy(src: StorageCopySource, dest: StorageCopyDestination, config?: any): Promise<any>;
|
67 | /**
|
68 | * Get a presigned URL of the file or the object data when download:true
|
69 | *
|
70 | * @param {string} key - key of the object
|
71 | * @param {Object} [config] - { level : private|protected|public, download: true|false }
|
72 | * @return - A promise resolves to either a presigned url or the object
|
73 | */
|
74 | get(key: string, config?: any): Promise<String | Object>;
|
75 | isCancelError(error: any): boolean;
|
76 | /**
|
77 | * Put a file in storage bucket specified to configure method
|
78 | * @param {string} key - key of the object
|
79 | * @param {Object} object - File to be put in bucket
|
80 | * @param {Object} [config] - { level : private|protected|public, contentType: MIME Types,
|
81 | * progressCallback: function }
|
82 | * @return - promise resolves to object on success
|
83 | */
|
84 | put(key: string, object: any, config?: any): Promise<Object>;
|
85 | /**
|
86 | * Remove the object for specified key
|
87 | * @param {string} key - key of the object
|
88 | * @param {Object} [config] - { level : private|protected|public }
|
89 | * @return - Promise resolves upon successful removal of the object
|
90 | */
|
91 | remove(key: string, config?: any): Promise<any>;
|
92 | /**
|
93 | * List bucket objects relative to the level and prefix specified
|
94 | * @param {String} path - the path that contains objects
|
95 | * @param {Object} [config] - { level : private|protected|public, maxKeys: NUMBER }
|
96 | * @return - Promise resolves to list of keys for all objects in path
|
97 | */
|
98 | list(path: any, config?: any): Promise<any>;
|
99 | }
|
100 | /**
|
101 | * @deprecated use named import
|
102 | */
|
103 | export default Storage;
|