README
nos-upload
安装和使用
$ npm install @winman-f2e/nos-upload
const nosUpload = {} // nos配置请查看内部wiki文档
const getUploader = require('@winman-f2e/nos-upload')
const { uploadByContent, uploadByPath, uploadByStream } = getUploader(nosUpload)
uploadByPath(
path.resolve(__dirname, './sentry-cli-Darwin-x86_64'), {
prefix: '1.52.3/',
name: 'sentry-cli-Darwin-x86_64',
hash: false
}
).then(url => console.log('uploadFile:', url))
.catch(err => console.log(err.message))
uploadByContent(
'lalalalalaasdfsd', {
prefix: 'fe_test/sub',
name: 'file',
ext: '.html',
hash: false
}
).then(url => console.log('uploadText:', url))
.catch(err => console.log(err.message))
const stream = require('stream');
const bufferData = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
const bufferStream = new stream.PassThrough();
bufferStream.end(bufferData);
//必须传入stream,以及它的length,不支持hash参数
uploadByStream(bufferStream, bufferData.length, {
prefix: 'snailreader_node',
name: 'screenshot' + Date.now(),
ext: '.' + type,
}).then(url => console.log('uploadText:', url))
.catch(err => console.log(err.message))
changelog
v2.2
增加stream上传接口,使用方式见/example/upload.js
:
v2
修改上传接口,使用方式见/example/upload.js
,参数信息见/index.js
注释