Delete aliyun.helper.ts

This commit is contained in:
fantasticit 2022-07-19 13:55:48 +08:00 committed by GitHub
parent b565883e75
commit d2616207a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 26 deletions

View File

@ -1,26 +0,0 @@
import { ConfigService } from '@nestjs/config';
import * as AliyunOSS from 'ali-oss';
export class AliyunOssClient {
configService: ConfigService;
constructor(config) {
this.configService = config;
}
private async buildClient() {
const config = this.configService.get('oss.aliyun');
return new AliyunOSS(config);
}
async putFile(filepath: string, buffer: ReadableStream) {
const client = await this.buildClient();
const { url } = await client.put(filepath, buffer);
return url;
}
async deleteFile(url: string) {
const client = await this.buildClient();
await client.delete(url);
}
}