egg-aliyun-utils
Introduction
This is a util collection for aliyun services.
STS
- Get Temporary Auth: It can get a temporary authorization from aliyun with the Access Key Id and Access Key Secret.
OSS
- Upload A File: Upload a file to aliyun oss.
Install
$ npm i egg-aliyun-utils --save
Usage
// {app_root}/config/plugin.jsexportsaliyunUtils = enable: true package: 'egg-aliyun-utils';
Configuration
// {app_root}/config/config.default.jsexportsaliyunUtils = {};
see config/config.default.js for more detail.
Example
// {app_root}/service/mainService.jsconst Service = ;const STS OSS = ;const toArray = ; async { const stsIns = accessKeyId: 'qwe' accessKeySecret: 'qwer' bucket: 'qwe' stsRoleId: 'acs:ram::123123123:role/keyirole' region: 'oss-cn-hangzhou' ; const roleSession = 'BrowserCheckFile'; const roleAction = '"oss:GetObject"'; const data = roleSession roleAction ; const result = await stsIns; return result; } async { const ossIns = accessKeyId: 'qwe' accessKeySecret: 'qwer' region: 'oss-cn-hangzhou' ; let stream; try stream = await ctx; catch e console; const parts = await ; const buffer = Buffer; const data = path: 'test' data: buffer bucket: 'qwe' ; const result = await ossIns; return result; } moduleexports = mainService;
Questions & Suggestions
Please open an issue here.
Author
Chris