akos-egg-nos
Install
$ npm i akos-egg-nos --save
Usage
exports.nos = {
enable: true,
package: 'akos-egg-nos',
};
Configuration
exports.nos = {
accessId: '',
secretId: '',
endpoint: '',
bucket: '',
port: '',
rmFile: '',
};
see config/config.default.js for more detail.
Example
const result = await this.app.nos.uploadFile(__dirname + '/home.js');
返回:
{
statusCode: 200,
headers: {
'date: 'Tue, 21 Jan 2020 07:10:12 GMT',
'content-type': 'application/javascript',
'content-length': '0',
'connection: 'close',
'x-nos-request-id': '5245eb29-fb6e-4e38-b30d-a15494f55b91',
'x-nos-requesttype': 'PutObject',
'x-nos-object-name': 'home_3fa36420c26b4f469c7bbc7ef1594402.js',
'etag: '7026e4bda37cf12fb33b15548ae645be',
'x-nos-storage-class': 'STANDARD',
'server': 'nos/v1.0.0'
},
file_key: 'home_3fa36420c26b4f469c7bbc7ef1594402.js'//文件名
}
// 获取文件地址
const key = 'test_358.txt';
const result = this.app.nos.getPrivateObjectUrl('testnos', key, 10 * 60 * 1000);
eg: result-> https://testnos.nos-eastchina1.126.net/test_358.txt?Signature=xxx&Expires=1579662403&NOSAccessKeyId=xxx
Questions & Suggestions
Please open an issue here.
License
MIT