Skip to content

Commit 5dc875f

Browse files
committed
feat(cos): support get object upload url
1 parent 0f1e299 commit 5dc875f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/baas/cos/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,20 @@ class Cos {
335335
})
336336
}
337337

338+
async getObjectUrl(inputs = {}) {
339+
const getObjectUrlHandler = util.promisify(this.cosClient.getObjectUrl.bind(this.cosClient))
340+
const { Url } = await getObjectUrlHandler({
341+
Bucket: inputs.bucket,
342+
Region: this.region,
343+
Key: inputs.object,
344+
// default expire time is 15min
345+
Expires: inputs.expires || 900,
346+
// default is sign url
347+
Sign: inputs.sign === false ? false : true
348+
})
349+
return Url
350+
}
351+
338352
async upload(inputs = {}) {
339353
console.log(`Uploding files to ${this.region}'s bucket: ${inputs.bucket} ...`)
340354

0 commit comments

Comments
 (0)