import { B2Coffin } from './b2'; import { DropboxCoffin } from './dropbox'; enum CoffinType { B2 = 'B2', Dropbox = 'Dropbox' } function createCoffin(config: { type: CoffinType.B2 }): B2Coffin; function createCoffin(config: { type: CoffinType.Dropbox }): DropboxCoffin; function createCoffin(config: { type: CoffinType }) { switch (config.type) { case CoffinType.B2: return new B2Coffin(); case CoffinType.Dropbox: return new DropboxCoffin(); } } async function main() { const coffin = createCoffin({ type: CoffinType.B2 }); await coffin.auth({ // applicationKeyId: '3afd39c093d6', // applicationKey: '00157326cf21bd4e096b83d69f538d4ed32a656200' applicationKeyId: '0013afd39c093d60000000005', applicationKey: 'K001EN5vtuLn3/GC1ibKH14D9Nfx6Eg' }); await coffin.listBuckets(); // coffin.put(); // await coffin.getUploadUrl(); // await coffin.upload(); // const coffin = createCoffin({ type: CoffinType.dropbox }); // await coffin.upload(); } main();