@annexwu-packages/cos-upload-utils
v0.0.10
Published
this is a utils which contains several cos upload functions
Downloads
49
Readme
@annexwu-packages/cos-upload-utils
Usage
const fs = require('fs');
const { CosUpload } = require('@annexwu-packages/cos-upload-utils');
async function test() {
const cosUpload = new CosUpload({
cos: {
SecretId: 'xxx',
SecretKey: 'xxx',
},
putObjectLimit: 5 * 1024 * 1024 * 1024,
defaultChunkSize: 8 * 1024 * 1024,
});
const result = await cosUpload.runTask({
object: {
Bucket: 'xxx',
Region: 'xxx',
Key: 'xxx',
ContentLength: 1024,
},
getRangeReadStream: (start, end) => {
return fs.createReadStream('xxx', { start, end: end - 1 });
},
getReadStream: () => {
return fs.createReadStream('xxx');
},
});
}
test();
API
CosUpload
Create a cos upload controller
const fs = require('fs');
const { CosUpload } = require('@annexwu-packages/cos-upload-utils');
async function test() {
const cosUpload = new CosUpload({
cos: {
SecretId: 'xxx',
SecretKey: 'xxx',
},
putObjectLimit: 5 * 1024 * 1024 * 1024,
defaultChunkSize: 8 * 1024 * 1024,
});
const result = await cosUpload.runTask({
object: {
Bucket: 'xxx',
Region: 'xxx',
Key: 'xxx',
ContentLength: 1024,
},
getRangeReadStream: (start, end) => {
return fs.createReadStream('xxx', { start, end: end - 1 });
},
getReadStream: () => {
return fs.createReadStream('xxx');
},
});
}
test();