mirror of https://github.com/fantasticit/think.git
Delete aliyun.helper.ts
This commit is contained in:
parent
b565883e75
commit
d2616207a4
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue