UNPKG

2.2 kBTypeScriptView Raw
1import { Nest } from "./nest";
2import { FileJob } from "./../job/fileJob";
3import { Environment } from "../environment/environment";
4export declare class S3Nest extends Nest {
5 protected client: any;
6 protected s3: any;
7 protected bucket: string;
8 protected keyPrefix: string;
9 protected checkEvery: number;
10 protected checkEveryMs: number;
11 protected allowCreation: boolean;
12 /**
13 * Constructor
14 * @param e
15 * @param bucket AWS S3 bucket to watch.
16 * @param keyPrefix Optional key prefix (sub-directory) to watch.
17 * @param checkEvery Frequency of bucket checking, in minutes.
18 * @param allowCreation Create the bucket:prefix if it does not exist.
19 */
20 constructor(e: Environment, bucket: string, keyPrefix?: string, checkEvery?: number, allowCreation?: boolean);
21 /**
22 * Set hard-coded AWS credentials.
23 * @param accessKeyId
24 * @param secretAccessKey
25 */
26 setCredentials(accessKeyId: string, secretAccessKey: string): void;
27 /**
28 * Verify bucket and handle creation of bucket if need be.
29 */
30 protected verifyBucket(): void;
31 /**
32 * Verify that the bucket is available and exists
33 * @param callback
34 */
35 protected headBucket(callback: any): void;
36 protected createBucket(callback: any): void;
37 load(): void;
38 /**
39 * Removes an object from an S3 bucket.
40 * @param key
41 */
42 protected deleteObject(key: any): void;
43 /**
44 * Watch an S3 bucket.
45 */
46 watch(): void;
47 /**
48 * Nest arrival
49 * @param job
50 */
51 arrive(job: FileJob): void;
52 /**
53 * Upload a file to an S3 bucket.
54 */
55 take(job: FileJob, callback?: any): void;
56 /**
57 * Calculate the percent remaining from the httpUploadProgress event values.
58 * @param total
59 * @param loaded
60 * @param part
61 * @returns {number}
62 */
63 private calculateRemaining(total, loaded, part?);
64 /**
65 * Upload file to S3
66 * @param job {FileJob} FileJob to be uploaded.
67 * @param callback Callback includes the S3FileJob parameter.
68 */
69 protected uploadFile(job: FileJob, callback: any): void;
70}