UNPKG

581 BPlain TextView Raw
1import { Bucket, BucketFile } from './bucket-base';
2import { GcpBucketCfg, getGcpBucket } from './bucket-gcp';
3import { getAwsBucket, AwsBucketCfg } from './bucket-aws';
4
5export { Bucket, BucketFile };
6
7
8export async function getBucket(rawCfg: any): Promise<Bucket> {
9
10 // if has .project_id, assume GcpBucket
11 if (rawCfg.project_id) {
12 return getGcpBucket(rawCfg as GcpBucketCfg);
13 } else if (rawCfg.access_key_id) {
14 return getAwsBucket(rawCfg as AwsBucketCfg);
15 }
16 else {
17 throw new Error(`bucket config does not seem to be valid (only support Gcp and Aws for now)`);
18 }
19
20}
21