egg-qswift

1.0.2 • Public • Published

egg-qswift

qunar swift for egg

Install

npm i egg-qswift --save

Usage

// {app_root}/config/plugin.js
exports.qswift = {
  enable: true,
  package: 'egg-qswift',
};

Configuration

// {app_root}/config/config.default.js
exports.qswift = {
    authUrl: 'http://xxx/auth/v1.0',
    userName: 'xxxx',
    userPassword: 'yyyy'
};

如果出现错误,会往 common-error.log 中记录,而不会抛出异常。

see config/config.default.js for more detail.

Example

上传图片

# 上传文件流,非 Node.js 中的流
const requestStream = await ctx.getFileStream();
const result = await ctx.qswift.put(requestStream);

返回值

{
    ret: true,
    data: '/application/795e5c9a5d380c4ce129f11d7dcad150.xlsx'
}

默认以文件 mimeType 作为 container

上传指定路径的文件

const result = await ctx.qswift.putByPath(filePath);

自定义 container

const requestStream = await ctx.getFileStream();
const result = await ctx.qswift.put(requestStream, abc);

返回值

{
    ret: true,
    data: '/abc/795e5c9a5d380c4ce129f11d7dcad150.xlsx'
}

Questions & Suggestions

Please open an issue here.

Version

Node >= 8.0.0

License

MIT

Package Sidebar

Install

npm i egg-qswift

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

13 kB

Total Files

6

Last publish

Collaborators

  • xbf321