diff --git a/lib/index.ts b/lib/index.ts index 2663ca0..ee75134 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -54,6 +54,8 @@ export = { const cos = new COS(COSInitConfig); return { + upload, + uploadStream: upload, delete(file: File): Promise { @@ -114,6 +116,7 @@ export = { } function upload(file: File): Promise { + if (!file.stream && !file.buffer) return Promise.reject(new Error('Missing Readable Stream or Buffer')); const Key = getFileKey(file) return new Promise((resolve, reject) => { cos.putObject( @@ -122,7 +125,7 @@ export = { Bucket, Region, Key, - Body: file.stream, + Body: file.stream || file.buffer, ContentLength: kbytesToBytes(file.size), ContentType: file.mime, }, diff --git a/package.json b/package.json index cb98a39..b01b001 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "strapi-provider-upload-tencent-cloud-storage", - "version": "1.0.7", + "version": "1.0.8", "description": "A integration of Tencent Cloud COS as a file storage solution within Strapi.", "main": "dist/index.js", "directories": {