Skip to content

Commit

Permalink
fix: upload by buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
yclgkd committed Aug 17, 2023
1 parent 140bb71 commit f867db2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export = {
const cos = new COS(COSInitConfig);

return {
upload,

uploadStream: upload,

delete(file: File): Promise<void> {
Expand Down Expand Up @@ -114,6 +116,7 @@ export = {
}

function upload(file: File): Promise<void> {
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(
Expand All @@ -122,7 +125,7 @@ export = {
Bucket,
Region,
Key,
Body: file.stream,
Body: file.stream || file.buffer,
ContentLength: kbytesToBytes(file.size),
ContentType: file.mime,
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit f867db2

Please sign in to comment.