UNPKG

3.5 kBTypeScriptView Raw
1import { StorageProvider } from './types';
2/**
3 * Provide storage methods to use AWS S3
4 */
5export 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 * Get a presigned URL of the file or the object data when download:true
60 *
61 * @param {string} key - key of the object
62 * @param {Object} [config] - { level : private|protected|public, download: true|false }
63 * @return - A promise resolves to either a presigned url or the object
64 */
65 get(key: string, config?: any): Promise<String | Object>;
66 isCancelError(error: any): boolean;
67 /**
68 * Put a file in storage bucket specified to configure method
69 * @param {string} key - key of the object
70 * @param {Object} object - File to be put in bucket
71 * @param {Object} [config] - { level : private|protected|public, contentType: MIME Types,
72 * progressCallback: function }
73 * @return - promise resolves to object on success
74 */
75 put(key: string, object: any, config?: any): Promise<Object>;
76 /**
77 * Remove the object for specified key
78 * @param {string} key - key of the object
79 * @param {Object} [config] - { level : private|protected|public }
80 * @return - Promise resolves upon successful removal of the object
81 */
82 remove(key: string, config?: any): Promise<any>;
83 /**
84 * List bucket objects relative to the level and prefix specified
85 * @param {String} path - the path that contains objects
86 * @param {Object} [config] - { level : private|protected|public, maxKeys: NUMBER }
87 * @return - Promise resolves to list of keys for all objects in path
88 */
89 list(path: any, config?: any): Promise<any>;
90}
91/**
92 * @deprecated use named import
93 */
94export default Storage;