| 'use strict'; | ||
| module.exports = { | ||
| /** | ||
| * OSS Singleton instance | ||
| * @member Context#oss | ||
| * @since 1.0.0 | ||
| * @see App#oss | ||
| */ | ||
| get oss() { | ||
| return this.app.oss; | ||
| }, | ||
| }; |
| 1.0.1 / 2017-02-07 | ||
| =================== | ||
| * init version |
+27
-25
| { | ||
| "name": "egg-oss", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "description": "oss plugin for egg", | ||
@@ -8,39 +8,41 @@ "eggPlugin": { | ||
| }, | ||
| "files": [ | ||
| "app", | ||
| "lib", | ||
| "config", | ||
| "agent.js", | ||
| "app.js" | ||
| ], | ||
| "keywords": [ | ||
| "egg", | ||
| "plugin" | ||
| "egg-plugin", | ||
| "eggPlugin" | ||
| ], | ||
| "dependencies": { | ||
| "ali-oss": "~4.4.4", | ||
| "is-type-of": "~1.0.0" | ||
| "ali-oss": "^4.8.0" | ||
| }, | ||
| "devDependencies": { | ||
| "ali-oss": "^4.4.4", | ||
| "autod": "^2", | ||
| "autod": "^2.7.1", | ||
| "co": "^4.6.0", | ||
| "egg": "~0.1.3", | ||
| "egg-bin": "^1", | ||
| "egg-ci": "^1", | ||
| "egg-mock": "^0.0.4", | ||
| "eslint": "^3", | ||
| "eslint-config-egg": "^3", | ||
| "pedding": "~1.0.0", | ||
| "should": "^8", | ||
| "supertest": "^1", | ||
| "urllib": "~2.13.0" | ||
| "egg": "^0.9.0", | ||
| "egg-bin": "^2.0.2", | ||
| "egg-mock": "^2.3.1", | ||
| "eslint": "^3.14.1", | ||
| "eslint-config-egg": "^3.2.0", | ||
| "is-type-of": "^1.0.0", | ||
| "pedding": "^1.1.0", | ||
| "supertest": "^3.0.0", | ||
| "urllib": "2" | ||
| }, | ||
| "engines": { | ||
| "node": ">=4.0.0" | ||
| "node": ">=6.0.0" | ||
| }, | ||
| "scripts": { | ||
| "test": "npm run lint && npm run test-local", | ||
| "test-local": "egg-bin test -r should", | ||
| "autod": "autod", | ||
| "lint": "eslint .", | ||
| "test": "npm run lint -- --fix && npm run test-local", | ||
| "test-local": "egg-bin test", | ||
| "cov": "egg-bin cov", | ||
| "lint": "eslint --ext js . --fix", | ||
| "ci": "npm run lint && npm run cov", | ||
| "autod": "autod" | ||
| "ci": "npm run lint && npm run cov" | ||
| }, | ||
| "ci": { | ||
| "version": "4, 6" | ||
| }, | ||
| "repository": { | ||
@@ -47,0 +49,0 @@ "type": "git", |
+9
-1
@@ -96,3 +96,4 @@ # egg-oss | ||
| let part; | ||
| while ((part = yield parts) !== null) { | ||
| part = yield parts; | ||
| while (part) { | ||
| if (part.length) { | ||
@@ -113,2 +114,3 @@ // arrays are busboy fields | ||
| } | ||
| part = yield parts; | ||
| } | ||
@@ -179,4 +181,10 @@ console.log('and we are done parsing the form!'); | ||
| ## secure keys | ||
| ping @fengmk2 to give you the access key! | ||
| - [oss secure keys](https://sharelock.io/1/d4dxf7wWoRP2Bh1ogtu4SfP_yt735noKhBld409yX84.acpMDn/-vOrQ4j4BpkMoxKkMeEavhwwUf0d293WY0WzHWDm-iVd8jbSwL/XEd43LrRzS7qmli4oJbbX_GcmG_X4KRu9pCMARJH4n92ebbtP1/y0fqwtoyV3JnK2ZdTJ4Ynky_ZVt7RR_Ji8DhLpn2N9j-A1BabK/FxYHfdXtUUrG4nd0PzN18_W2SuEr8Eyyqc6SHpFHt3qrgdSRse/giuXaV_3igL1CipdL5F5Vy2iDxjeRb_Zt_8Xlkmg1frfQTcnfZ/sfnl9zNYqOBzjGlC8f6YI6dDvShM-o1VoKp5F_kcXok1lAiLt4/3TnriQ6YM-qcx3wL7wgHu7TbzN_-4FN3ijpVOHkIVNPXjIquxL/SfKBlmu50XnZrYetixa0fvlbrc2yIAKx7cPQUxUe33b6Ti8N8b/U_rIfAGGL_8hK4XRLMWGdVevbSbw0IHgokTm6zGvpHj9PEILtP/wGJ5l3-hW6Chr5FJYJO1Wv0H4haJGctf3K2fg40ku8sx7511qv/h8xnoUyQmM0jkRrysIAD7FcW5mplMcvIOVd_CyugoH-NZCZfE1/maLQF303M3Y5_6kLBhF_Yi3jwO-UX7pTFt_Ax_ATh6Wvvix4JC/MjK891qkm4_vumc_Y86XB6HpchO7ox4nW5m2jUJlP016sBEnMw/bKE0FaX2SQ.WSqThAUsnFO7ddCpRJuotw) | ||
| ## License | ||
| [MIT](LICENSE) |
| 'use strict'; | ||
| module.exports = { | ||
| write: true, | ||
| prefix: '^', | ||
| test: [ | ||
| 'test', | ||
| 'benchmark', | ||
| ], | ||
| devdep: [ | ||
| 'egg-ci', | ||
| 'egg-bin', | ||
| 'autod', | ||
| 'eslint', | ||
| 'eslint-config-egg', | ||
| 'supertest', | ||
| 'should', | ||
| ], | ||
| exclude: [ | ||
| './test/fixtures', | ||
| ], | ||
| } |
Sorry, the diff of this file is not supported yet
| { | ||
| "extends": "eslint-config-egg" | ||
| } |
| <!-- | ||
| Thank you for reporting an issue. | ||
| 1. It's RECOMMENDED to submit PR for typo or tiny bug fix. | ||
| 2. If this's a BUG, please provide: course repetition, error log and configuration. Fill in as much of the template below as you're able. | ||
| 3. If this's a FEATURE request, please provide: details, pseudo codes if necessary. | ||
| 感谢您向我们反馈问题。 | ||
| 1. 我们推荐如果是小问题(错别字修改,小的 bug fix)直接提交 PR。 | ||
| 2. 如果是一个 BUG,请提供:复现步骤,错误日志以及相关配置,并尽量填写下面的模板中的条目。 | ||
| 3. 如果是一个新需求,请提供:详细需求描述,最好是有伪代码实现。 | ||
| --> | ||
| * **Node Version**: | ||
| * **Egg Version**: | ||
| * **Plugin Name**: | ||
| * **Plugin Version**: | ||
| * **Platform**: | ||
| <!-- Enter your issue details below this comment. --> |
| <!-- | ||
| Thank you for your pull request. Please review below requirements. | ||
| Bug fixes and new features should include tests and possibly benchmarks. | ||
| Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md | ||
| 感谢您贡献代码。请确认下列 checklist 的完成情况。 | ||
| Bug 修复和新功能必须包含测试,必要时请附上性能测试。 | ||
| Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md | ||
| --> | ||
| ##### Checklist | ||
| <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> | ||
| - [ ] `npm test` passes | ||
| - [ ] tests and/or benchmarks are included | ||
| - [ ] documentation is changed or added | ||
| - [ ] commit message follows commit guidelines | ||
| ##### Affected core subsystem(s) | ||
| <!-- Provide affected core subsystem(s). --> | ||
| ##### Description of change | ||
| <!-- Provide a description of the change below this comment. --> |
Sorry, the diff of this file is not supported yet
-21
| sudo: false | ||
| language: node_js | ||
| node_js: | ||
| - '4' | ||
| - '6' | ||
| install: | ||
| - npm i npminstall && npminstall | ||
| script: | ||
| - npm run ci | ||
| after_script: | ||
| - npminstall codecov && codecov | ||
| env: | ||
| global: | ||
| - secure: Ws1h7ZU97/2npejMZp3/Jac0ZYkgXBW5gEilR5WrnkdkEbIhhK6HamrcqLrA6qCPV0Ax9nNbZCRJcQwPsTdOxBekJ3+3zflMWevfa9+CRS1Hh0mMcn+D864CjrRiQRgIQa8ZoFVPLaL/7qyQp1i7gLbPcpMjO6CA7LgV1reaf+U= | ||
| - secure: Sj56ZeEZ48Sms7+jEI0qvrtEZoGc5ywotxYxvZ3EHg42Xpv6HBE6aEl3AZhz8ggQgmtJ/AneWLAZGOnZHpQiVrMetUa46HcAzCJ0h/wJXechpyu/KRTqaDjHkn3lD0yi+WnvBTYUIBr+Db8VwLbbcRVM2h/GxgBnWBTaE6jlmag= | ||
| - secure: WixkbIJUiMfk4YZ+6Unlya1zxBl0i8X90O6xjd+gGogTf2IHeNUM8alLAMe9uFajbQnej8vKI+Lx9DTfaICtEoacjuG0UX8udZgMMyGxwBc36FJbUxeTtXpXp/PIz0rjmEGdIlFrjReMFcPjgOvyPdSNtUXYPACfGQFEhy69nJM= | ||
| - secure: PADJkH7wZP4vfIhvobEW66vmqQuIu6LZH2fcQ+aFRPiOCLU18jRiyKIMzAT9+igQTS5/nLGOJP1O94rD0wXpf7A07fK3DUYOGvC/kzD/Gdh/EkcjeyrL/EX7vITeVZJIxlUVE/F5WHDs04Xpezi4DlsE0v1WBj/Im+JKR7yyoZA= | ||
| - secure: A5B0GOXgKRNLc1+EAISSpxZeD9ZlPHJlv1vGUMXWv9qiR9KnZofh1GZYDbVKgOdbfPKSWgvb9vp8m1WPebOj8q/rT+DyfqRuKhqhQ2AudP2AcOBOATaOvLIMFrh4E+qdcvFq65A+nhg0b6EkINQjxrRyts/6gaAnQbshrYbElsc= | ||
| - secure: bf2G/bsk8+7xBU3zVF47/U5+kfpcyBv14dNkiQzax9r9fyhUlyKSyDsoWbGKijWYYmp9vjQlo9ymhmnRP5+zKho9XhJ5qteZmElCtQkwvAmKVIeZPbTcYA+ofagU2WCggF4k3R/YtXRX8P+Ie/+ge1dhq4YX1fmbDWXalRdhO7M= | ||
| - secure: F8d9Ix7IlWTA0XcxgxTlqzyIBkGJ0fT2YAa3GbpknU4KfrgK5rTzWNmN8N7Q2acxArjFRp2pYjFL/RlL8pI2skvj1HDK3FTABQh0cyBShhiuQLgm0xUSC3JSltpPBF4wEoC6Pdjd9oF1moc900A4g+pjCf/fx7vYm5GxnyHTKHI= | ||
| - secure: Og1xl8+NoUfc3ZlWT/yVOPy/8YhRHVNT2M+LVZ81iRwJNBxwm1cj40cck41Py2eG3AwH0yCj0K3u+o74fOHbTuYLzNskB1gYbA8m6v2vuMnGRblb6+UYEm3yUcYHJ4VXFMmFTMKyNoe/iqEpetgoKffbCAk3Xa7kZbbQR7T03tI= |
| 'use strict'; | ||
| module.exports = { | ||
| /** | ||
| * OSS Singleton 实例 | ||
| * @member Context#oss | ||
| * @since 1.0.0 | ||
| * @see App#oss | ||
| */ | ||
| get oss() { | ||
| return this.app.oss; | ||
| }, | ||
| }; |
-15
| environment: | ||
| matrix: | ||
| - nodejs_version: '4' | ||
| - nodejs_version: '6' | ||
| install: | ||
| - ps: Install-Product node $env:nodejs_version | ||
| - npm i npminstall && node_modules\.bin\npminstall | ||
| test_script: | ||
| - node --version | ||
| - npm --version | ||
| - npm run ci | ||
| build: off |
| 'use strict'; | ||
| const co = require('co'); | ||
| const fs = require('fs'); | ||
| module.exports = agent => { | ||
| agent.messenger.on('oss start', () => { | ||
| co.call(agent, function*() { | ||
| const name = 'chair-oss-test-upload-' + process.version + '-' + Date.now(); | ||
| yield this.oss.put(name, fs.createReadStream(__filename)); | ||
| this.messenger.broadcast('oss done'); | ||
| }); | ||
| }); | ||
| }; |
| 'use strict'; | ||
| module.exports = app => { | ||
| app.get('/agent', function*() { | ||
| yield wrapPromise(app); | ||
| this.body = 'OK'; | ||
| }); | ||
| }; | ||
| function wrapPromise(app) { | ||
| const d = Promise.defer(); | ||
| app.messenger.broadcast('oss start'); | ||
| app.messenger.on('oss done', () => { | ||
| d.resolve(); | ||
| }); | ||
| return d.promise; | ||
| } |
| 'use strict'; | ||
| let env = process.env; | ||
| exports.oss = { | ||
| client: { | ||
| accessKeyId: env.ALI_SDK_OSS_ID, | ||
| accessKeySecret: env.ALI_SDK_OSS_SECRET, | ||
| endpoint: env.ALI_SDK_OSS_ENDPOINT, | ||
| bucket: 'ali-oss-test-bucket-test99', | ||
| }, | ||
| useAgent: true, | ||
| }; |
| 2016-09-26 13:34:28,024 INFO 41498 [egg:watcher:agent] watcher start success | ||
| 2016-09-26 13:34:27,808 INFO 41498 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-agent/logs/oss-agent","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-agent/logs/oss-agent"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-agent-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"agent"} | ||
| 2016-09-26 13:34:27,817 INFO 41498 [egg:agent] create an AgentWorkerClient for "watcher" |
| 2016-09-26 13:34:28,765 INFO 41499 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-agent/logs/oss-agent","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-agent/logs/oss-agent"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-agent-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"application"} | ||
| 2016-09-26 13:34:28,767 INFO 41499 [egg:worker] create an AppWorkerClient for "watcher" | ||
| 2016-09-26 13:34:28,829 INFO 41499 [egg-schedule]: register schedule egg-schedule:/Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-logrotator/app/schedule/rotate_by_file.js | ||
| 2016-09-26 13:34:29,017 INFO 41499 [egg-security] use csrf middleware | ||
| 2016-09-26 13:34:29,019 INFO 41499 [egg-security] use methodnoallow middleware | ||
| 2016-09-26 13:34:29,019 INFO 41499 [egg-security] use noopen middleware | ||
| 2016-09-26 13:34:29,020 INFO 41499 [egg-security] use nosniff middleware | ||
| 2016-09-26 13:34:29,020 INFO 41499 [egg-security] use xssProtection middleware | ||
| 2016-09-26 13:34:29,020 INFO 41499 [egg-security] use xframe middleware | ||
| 2016-09-26 13:34:29,021 INFO 41499 [egg-security] compose 6 middlewares into one security middleware |
| { | ||
| "name": "oss-agent" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| 'use strict'; | ||
| const fs = require('fs'); | ||
| module.exports = function(app) { | ||
| app.get('/uploadtest', function*() { | ||
| const name = 'oss-test-upload-' + process.version + '-' + Date.now(); | ||
| this.body = yield this.oss.get('oss2').put(name, fs.createReadStream(__filename)); | ||
| }); | ||
| }; |
| <form method="POST" action="/upload?_csrf={{ ctx.csrf | safe }}" enctype="multipart/form-data"> | ||
| title: <input name="title" /><br/> | ||
| file: <input name="file" type="file" /> | ||
| <button type="submit">上传</button> | ||
| </form> |
| 'use strict'; | ||
| let env = process.env; | ||
| exports.oss = { | ||
| clients: { | ||
| oss1: { | ||
| accessKeyId: env.ALI_SDK_OSS_ID, | ||
| accessKeySecret: env.ALI_SDK_OSS_SECRET, | ||
| }, | ||
| oss2: { | ||
| accessKeyId: env.ALI_SDK_OSS_ID, | ||
| accessKeySecret: env.ALI_SDK_OSS_SECRET, | ||
| }, | ||
| }, | ||
| default: { | ||
| endpoint: env.ALI_SDK_OSS_ENDPOINT, | ||
| bucket:'ali-oss-test-bucket-test99' | ||
| }, | ||
| }; |
| 2016-09-26 13:34:29,157 INFO 41496 [egg:watcher:agent] watcher start success | ||
| 2016-09-26 13:34:29,127 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-clients/logs/oss-clients","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-clients/logs/oss-clients"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-clients-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"agent"} | ||
| 2016-09-26 13:34:29,130 INFO 41496 [egg:agent] create an AgentWorkerClient for "watcher" |
| 2016-09-26 13:34:29,172 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-clients/logs/oss-clients","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-clients/logs/oss-clients"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-clients-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"application"} | ||
| 2016-09-26 13:34:29,173 INFO 41496 [egg:worker] create an AppWorkerClient for "watcher" | ||
| 2016-09-26 13:34:29,175 INFO 41496 [egg-schedule]: register schedule egg-schedule:/Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-logrotator/app/schedule/rotate_by_file.js | ||
| 2016-09-26 13:34:29,186 INFO 41496 [egg-security] use csrf middleware | ||
| 2016-09-26 13:34:29,186 INFO 41496 [egg-security] use methodnoallow middleware | ||
| 2016-09-26 13:34:29,186 INFO 41496 [egg-security] use noopen middleware | ||
| 2016-09-26 13:34:29,186 INFO 41496 [egg-security] use nosniff middleware | ||
| 2016-09-26 13:34:29,186 INFO 41496 [egg-security] use xssProtection middleware | ||
| 2016-09-26 13:34:29,186 INFO 41496 [egg-security] use xframe middleware | ||
| 2016-09-26 13:34:29,186 INFO 41496 [egg-security] compose 6 middlewares into one security middleware |
| { | ||
| "name": "oss-clients" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| 'use strict'; | ||
| const path = require('path'); | ||
| const fs = require('fs'); | ||
| const is = require('is-type-of'); | ||
| module.exports = function(app) { | ||
| app.get('/', function*() { | ||
| this.body = { | ||
| app: is.object(this.app.oss), | ||
| ctx: is.object(this.oss), | ||
| putBucket: is.generatorFunction(this.oss.putBucket) | ||
| } | ||
| }); | ||
| app.get('/uploadtest', function*() { | ||
| const name = 'oss-test-upload-' + process.version + '-' + Date.now(); | ||
| this.body = yield this.oss.put(name, fs.createReadStream(__filename)); | ||
| }); | ||
| app.get('/upload', function*() { | ||
| this.set('x-csrf', this.csrf); | ||
| yield this.render('upload.html'); | ||
| }); | ||
| app.post('/upload', function*() { | ||
| const stream = yield this.getFileStream(); | ||
| const name = 'multipart-test/' + process.version + '-' + Date.now() + '-' + path.basename(stream.filename); | ||
| // 文件处理,上传到云存储等等 | ||
| const result = yield this.oss.put(name, stream); | ||
| this.body = { | ||
| name: result.name, | ||
| url: result.url, | ||
| status: result.res.status, | ||
| fields: stream.fields, | ||
| }; | ||
| }); | ||
| }; |
| <form method="POST" action="/upload?_csrf={{ ctx.csrf | safe }}" enctype="multipart/form-data"> | ||
| title: <input name="title" /><br/> | ||
| file: <input name="file" type="file" /> | ||
| <button type="submit">上传</button> | ||
| </form> |
| 'use strict'; | ||
| let env = process.env; | ||
| exports.oss = { | ||
| client: { | ||
| cluster: [{ | ||
| accessKeyId: env.ALI_SDK_OSS_ID, | ||
| accessKeySecret: env.ALI_SDK_OSS_SECRET, | ||
| endpoint: env.ALI_SDK_OSS_ENDPOINT, | ||
| bucket: 'ali-oss-test-bucket-test99' | ||
| }, { | ||
| accessKeyId: env.ALI_SDK_OSS_ID, | ||
| accessKeySecret: env.ALI_SDK_OSS_SECRET, | ||
| endpoint: env.ALI_SDK_OSS_ENDPOINT, | ||
| bucket: 'ali-oss-test-bucket-test99' | ||
| }] | ||
| } | ||
| }; |
| 2016-09-26 13:34:26,937 INFO 41496 [egg:watcher:agent] watcher start success | ||
| 2016-09-26 13:34:26,910 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-cluster/logs/oss","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-cluster/logs/oss"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"agent"} | ||
| 2016-09-26 13:34:26,911 INFO 41496 [egg:agent] create an AgentWorkerClient for "watcher" |
| 2016-09-26 13:34:26,951 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-cluster/logs/oss","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-cluster/logs/oss"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"application"} | ||
| 2016-09-26 13:34:26,951 INFO 41496 [egg:worker] create an AppWorkerClient for "watcher" | ||
| 2016-09-26 13:34:26,952 INFO 41496 [egg-schedule]: register schedule egg-schedule:/Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-logrotator/app/schedule/rotate_by_file.js | ||
| 2016-09-26 13:34:26,967 INFO 41496 [egg-security] use csrf middleware | ||
| 2016-09-26 13:34:26,967 INFO 41496 [egg-security] use methodnoallow middleware | ||
| 2016-09-26 13:34:26,967 INFO 41496 [egg-security] use noopen middleware | ||
| 2016-09-26 13:34:26,967 INFO 41496 [egg-security] use nosniff middleware | ||
| 2016-09-26 13:34:26,967 INFO 41496 [egg-security] use xssProtection middleware | ||
| 2016-09-26 13:34:26,967 INFO 41496 [egg-security] use xframe middleware | ||
| 2016-09-26 13:34:26,967 INFO 41496 [egg-security] compose 6 middlewares into one security middleware |
| { | ||
| "name": "oss" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| 'use strict'; | ||
| const path = require('path'); | ||
| const fs = require('fs'); | ||
| const is = require('is-type-of'); | ||
| module.exports = function(app) { | ||
| app.get('/', function*() { | ||
| this.body = { | ||
| app: is.object(this.app.oss), | ||
| ctx: is.object(this.oss), | ||
| putBucket: is.generatorFunction(this.oss.putBucket) | ||
| } | ||
| }); | ||
| app.get('/uploadtest', function*() { | ||
| const name = 'oss-test-upload-' + process.version + '-' + Date.now(); | ||
| this.body = yield this.oss.put(name, fs.createReadStream(__filename)); | ||
| }); | ||
| app.get('/upload', function*() { | ||
| this.set('x-csrf', this.csrf); | ||
| yield this.render('upload.html'); | ||
| }); | ||
| app.post('/upload', function*() { | ||
| const stream = yield this.getFileStream(); | ||
| const name = 'multipart-test/' + process.version + '-' + Date.now() + '-' + path.basename(stream.filename); | ||
| // 文件处理,上传到云存储等等 | ||
| const result = yield this.oss.put(name, stream); | ||
| this.body = { | ||
| name: result.name, | ||
| url: result.url, | ||
| status: result.res.status, | ||
| fields: stream.fields, | ||
| }; | ||
| }); | ||
| }; |
| <form method="POST" action="/upload?_csrf={{ ctx.csrf | safe }}" enctype="multipart/form-data"> | ||
| title: <input name="title" /><br/> | ||
| file: <input name="file" type="file" /> | ||
| <button type="submit">上传</button> | ||
| </form> |
| 'use strict'; | ||
| let env = process.env; | ||
| exports.oss = { | ||
| client: { | ||
| accessKeyId: env.ALI_SDK_OSS_ID, | ||
| accessKeySecret: env.ALI_SDK_OSS_SECRET, | ||
| endpoint: env.ALI_SDK_OSS_ENDPOINT, | ||
| bucket:'ali-oss-test-bucket-test99' | ||
| } | ||
| }; |
| 2016-09-26 13:34:26,541 INFO 41496 [egg:watcher:agent] watcher start success | ||
| 2016-09-26 13:34:26,508 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-endpoint-http/logs/oss","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-endpoint-http/logs/oss"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"agent"} | ||
| 2016-09-26 13:34:26,508 INFO 41496 [egg:agent] create an AgentWorkerClient for "watcher" |
| 2016-09-26 13:34:26,567 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-endpoint-http/logs/oss","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-endpoint-http/logs/oss"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"application"} | ||
| 2016-09-26 13:34:26,568 INFO 41496 [egg:worker] create an AppWorkerClient for "watcher" | ||
| 2016-09-26 13:34:26,569 INFO 41496 [egg-schedule]: register schedule egg-schedule:/Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-logrotator/app/schedule/rotate_by_file.js | ||
| 2016-09-26 13:34:26,581 INFO 41496 [egg-security] use csrf middleware | ||
| 2016-09-26 13:34:26,581 INFO 41496 [egg-security] use methodnoallow middleware | ||
| 2016-09-26 13:34:26,582 INFO 41496 [egg-security] use noopen middleware | ||
| 2016-09-26 13:34:26,582 INFO 41496 [egg-security] use nosniff middleware | ||
| 2016-09-26 13:34:26,582 INFO 41496 [egg-security] use xssProtection middleware | ||
| 2016-09-26 13:34:26,582 INFO 41496 [egg-security] use xframe middleware | ||
| 2016-09-26 13:34:26,582 INFO 41496 [egg-security] compose 6 middlewares into one security middleware |
| { | ||
| "name": "oss" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| 'use strict'; | ||
| let env = process.env; | ||
| exports.oss = { | ||
| client: { | ||
| accessKeyId: env.ALI_SDK_OSS_ID, | ||
| endpoint: env.ALI_SDK_OSS_ENDPOINT, | ||
| bucket:'ali-oss-test-bucket-test99' | ||
| } | ||
| }; |
| 2016-09-26 13:34:26,697 ERROR 41496 nodejs.AssertionError: [egg-oss] Must set `accessKeyId` and `accessKeySecret` in oss's config | ||
| at checkBucketConfig (/Users/adams/Documents/code/egg-oss-github/lib/oss.js:10:3) | ||
| at Singleton.create (/Users/adams/Documents/code/egg-oss-github/lib/oss.js:26:5) | ||
| at Singleton.createInstance (/Users/adams/Documents/code/egg-oss-github/node_modules/egg/lib/core/singleton.js:53:17) | ||
| at Singleton.init (/Users/adams/Documents/code/egg-oss-github/node_modules/egg/lib/core/singleton.js:27:27) | ||
| at MockApplication.addSingleton (/Users/adams/Documents/code/egg-oss-github/node_modules/egg/app/extend/application.js:112:15) | ||
| at module.exports.app.addSingleton (/Users/adams/Documents/code/egg-oss-github/lib/oss.js:19:7) | ||
| at module.exports.app (/Users/adams/Documents/code/egg-oss-github/app.js:6:3) | ||
| at MockLoader.loadFile (/Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-core/lib/loader/egg_loader.js:197:34) | ||
| at /Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-core/lib/loader/mixin/custom.js:25:29 | ||
| at Array.forEach (native) | ||
| at MockLoader.loadCustomApp (/Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-core/lib/loader/mixin/custom.js:25:8) | ||
| at MockLoader.load (/Users/adams/Documents/code/egg-oss-github/node_modules/egg/lib/loader/app_worker_loader.js:33:10) | ||
| at /Users/adams/Documents/code/egg-oss-github/node_modules/egg-mock/lib/app.js:64:19 | ||
| at process._tickCallback (node.js:382:9) | ||
| name: 'AssertionError' | ||
| actual: undefined | ||
| expected: true | ||
| operator: '==' | ||
| message: '[egg-oss] Must set `accessKeyId` and `accessKeySecret` in oss\'s config' | ||
| generatedMessage: false | ||
| pid: 41496 | ||
| hostname: adamsdeMacBook-Pro.local | ||
| 2016-09-26 13:34:26,661 INFO 41496 [egg:watcher:agent] watcher start success | ||
| 2016-09-26 13:34:26,632 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-missing-config/logs/oss-missing-config","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-missing-config/logs/oss-missing-config"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-missing-config-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"agent"} | ||
| 2016-09-26 13:34:26,633 INFO 41496 [egg:agent] create an AgentWorkerClient for "watcher" |
| 2016-09-26 13:34:26,678 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-missing-config/logs/oss-missing-config","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-missing-config/logs/oss-missing-config"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-missing-config-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"application"} | ||
| 2016-09-26 13:34:26,679 INFO 41496 [egg:worker] create an AppWorkerClient for "watcher" | ||
| 2016-09-26 13:34:26,680 INFO 41496 [egg-schedule]: register schedule egg-schedule:/Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-logrotator/app/schedule/rotate_by_file.js |
| { | ||
| "name": "oss-missing-config" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| 'use strict'; | ||
| module.exports = function(app) { | ||
| app.uploader = app.createOss(app.config.uploader); | ||
| }; |
| 'use strict'; | ||
| const path = require('path'); | ||
| const fs = require('fs'); | ||
| const is = require('is-type-of'); | ||
| module.exports = function(app) { | ||
| app.get('/', function*() { | ||
| this.body = { | ||
| app: is.object(this.app.oss), | ||
| ctx: is.object(this.app.uploader), | ||
| putBucket: is.generatorFunction(this.app.uploader.putBucket) | ||
| } | ||
| }); | ||
| app.get('/uploadtest', function*() { | ||
| const name = 'chair-oss-test-upload-' + process.version + '-' + Date.now(); | ||
| this.body = yield this.app.uploader.put(name, fs.createReadStream(__filename)); | ||
| }); | ||
| app.get('/upload', function*() { | ||
| this.set('x-csrf', this.csrf); | ||
| yield this.render('upload.html'); | ||
| }); | ||
| app.post('/upload', function*() { | ||
| const stream = yield this.getFileStream(); | ||
| const name = 'chair-multipart-test/' + process.version + '-' + Date.now() + '-' + path.basename(stream.filename); | ||
| // 文件处理,上传到云存储等等 | ||
| const result = yield this.app.uploader.put(name, stream); | ||
| this.body = { | ||
| name: result.name, | ||
| url: result.url, | ||
| status: result.res.status, | ||
| fields: stream.fields, | ||
| }; | ||
| }); | ||
| }; |
| <form method="POST" action="/upload?_csrf={{ ctx.csrf | safe }}" enctype="multipart/form-data"> | ||
| title: <input name="title" /><br/> | ||
| file: <input name="file" type="file" /> | ||
| <button type="submit">上传</button> | ||
| </form> |
| 'use strict'; | ||
| let env = process.env; | ||
| exports.uploader = { | ||
| accessKeyId: env.ALI_SDK_OSS_ID, | ||
| accessKeySecret: env.ALI_SDK_OSS_SECRET, | ||
| endpoint: env.ALI_SDK_OSS_ENDPOINT, | ||
| bucket:'ali-oss-test-bucket-test99' | ||
| }; | ||
| exports.oss = { | ||
| init: false, | ||
| }; |
| 2016-09-26 13:34:26,807 INFO 41496 [egg:watcher:agent] watcher start success | ||
| 2016-09-26 13:34:26,789 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-not-init/logs/oss-not-init","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-not-init/logs/oss-not-init"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-not-init-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"agent"} | ||
| 2016-09-26 13:34:26,789 INFO 41496 [egg:agent] create an AgentWorkerClient for "watcher" |
| 2016-09-26 13:34:26,822 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-not-init/logs/oss-not-init","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss-not-init/logs/oss-not-init"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-not-init-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"application"} | ||
| 2016-09-26 13:34:26,822 INFO 41496 [egg:worker] create an AppWorkerClient for "watcher" | ||
| 2016-09-26 13:34:26,824 INFO 41496 [egg-schedule]: register schedule egg-schedule:/Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-logrotator/app/schedule/rotate_by_file.js | ||
| 2016-09-26 13:34:26,836 INFO 41496 [egg-security] use csrf middleware | ||
| 2016-09-26 13:34:26,836 INFO 41496 [egg-security] use methodnoallow middleware | ||
| 2016-09-26 13:34:26,836 INFO 41496 [egg-security] use noopen middleware | ||
| 2016-09-26 13:34:26,836 INFO 41496 [egg-security] use nosniff middleware | ||
| 2016-09-26 13:34:26,836 INFO 41496 [egg-security] use xssProtection middleware | ||
| 2016-09-26 13:34:26,836 INFO 41496 [egg-security] use xframe middleware | ||
| 2016-09-26 13:34:26,836 INFO 41496 [egg-security] compose 6 middlewares into one security middleware |
| { | ||
| "name": "oss-not-init" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| 'use strict'; | ||
| const path = require('path'); | ||
| const fs = require('fs'); | ||
| const is = require('is-type-of'); | ||
| module.exports = function(app) { | ||
| app.get('/', function*() { | ||
| this.body = { | ||
| app: is.object(this.app.oss), | ||
| ctx: is.object(this.oss), | ||
| putBucket: is.generatorFunction(this.oss.putBucket) | ||
| } | ||
| }); | ||
| app.get('/uploadtest', function*() { | ||
| const name = 'oss-test-upload-' + process.version + '-' + Date.now(); | ||
| this.body = yield this.oss.put(name, fs.createReadStream(__filename)); | ||
| }); | ||
| app.get('/upload', function*() { | ||
| this.set('x-csrf', this.csrf); | ||
| yield this.render('upload.html'); | ||
| }); | ||
| app.post('/upload', function*() { | ||
| const stream = yield this.getFileStream(); | ||
| const name = 'multipart-test/' + process.version + '-' + Date.now() + '-' + path.basename(stream.filename); | ||
| // 文件处理,上传到云存储等等 | ||
| const result = yield this.oss.put(name, stream); | ||
| this.body = { | ||
| name: result.name, | ||
| url: result.url, | ||
| status: result.res.status, | ||
| fields: stream.fields, | ||
| }; | ||
| }); | ||
| }; |
| <form method="POST" action="/upload?_csrf={{ ctx.csrf | safe }}" enctype="multipart/form-data"> | ||
| title: <input name="title" /><br/> | ||
| file: <input name="file" type="file" /> | ||
| <button type="submit">上传</button> | ||
| </form> |
| 'use strict'; | ||
| let env = process.env; | ||
| exports.oss = { | ||
| client: { | ||
| accessKeyId: env.ALI_SDK_OSS_ID, | ||
| accessKeySecret: env.ALI_SDK_OSS_SECRET, | ||
| endpoint: env.ALI_SDK_OSS_ENDPOINT, | ||
| bucket: 'ali-oss-test-bucket-test99' | ||
| } | ||
| }; |
| 2016-09-26 13:34:26,122 INFO 41496 [egg:watcher:agent] watcher start success | ||
| 2016-09-26 13:34:26,048 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss/logs/oss","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss/logs/oss"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"agent"} | ||
| 2016-09-26 13:34:26,055 INFO 41496 [egg:agent] create an AgentWorkerClient for "watcher" |
| 2016-09-26 13:34:26,350 INFO 41496 [egg:logger] init all loggers with options: {"dir":"/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss/logs/oss","rotateLogDirs":["/Users/adams/Documents/code/egg-oss-github/test/fixtures/apps/oss/logs/oss"],"encoding":"utf8","env":"unittest","level":"INFO","consoleLevel":"WARN","outputJSON":false,"buffer":false,"appLogName":"oss-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"type":"application"} | ||
| 2016-09-26 13:34:26,351 INFO 41496 [egg:worker] create an AppWorkerClient for "watcher" | ||
| 2016-09-26 13:34:26,374 INFO 41496 [egg-schedule]: register schedule egg-schedule:/Users/adams/Documents/code/egg-oss-github/node_modules/egg/node_modules/egg-logrotator/app/schedule/rotate_by_file.js | ||
| 2016-09-26 13:34:26,466 INFO 41496 [egg-security] use csrf middleware | ||
| 2016-09-26 13:34:26,469 INFO 41496 [egg-security] use methodnoallow middleware | ||
| 2016-09-26 13:34:26,469 INFO 41496 [egg-security] use noopen middleware | ||
| 2016-09-26 13:34:26,470 INFO 41496 [egg-security] use nosniff middleware | ||
| 2016-09-26 13:34:26,471 INFO 41496 [egg-security] use xssProtection middleware | ||
| 2016-09-26 13:34:26,472 INFO 41496 [egg-security] use xframe middleware | ||
| 2016-09-26 13:34:26,472 INFO 41496 [egg-security] compose 6 middlewares into one security middleware |
| { | ||
| "name": "oss" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
-187
| 'use strict'; | ||
| const pedding = require('pedding'); | ||
| const mm = require('egg-mock'); | ||
| const request = require('supertest'); | ||
| const oss = require('ali-oss'); | ||
| const config = require('./fixtures/apps/oss/config/config.default').oss.client; | ||
| const assert = require('assert'); | ||
| const env = process.env; | ||
| const region = env.ALI_SDK_OSS_REGION || 'oss-cn-hangzhou'; | ||
| describe('test/oss.test.js', () => { | ||
| afterEach(mm.restore); | ||
| describe('oss', () => { | ||
| let app; | ||
| let lastUploadFileName; | ||
| before(function* () { | ||
| const ossConfig = { | ||
| accessKeyId: config.accessKeyId, | ||
| accessKeySecret: config.accessKeySecret, | ||
| endpoint: config.endpoint, | ||
| region, | ||
| callbackServer: 'http://d.rockuw.com:4567', | ||
| }; | ||
| const store = oss(ossConfig); | ||
| const bucket = 'ali-oss-test-bucket-test99'; | ||
| const result = yield store.putBucket(bucket, region); | ||
| assert.equal(result.bucket, bucket); | ||
| assert.equal(result.res.status, 200); | ||
| app = mm.app({ | ||
| baseDir: 'apps/oss', | ||
| }); | ||
| return app.ready(); | ||
| }); | ||
| after(function* () { | ||
| if (lastUploadFileName) { | ||
| yield app.oss.delete(lastUploadFileName); | ||
| } | ||
| app.close(); | ||
| }); | ||
| it('https?://endpoint should replace', function(done) { | ||
| const ta = mm.app({ | ||
| baseDir: 'apps/oss-endpoint-http', | ||
| }); | ||
| ta.ready(function() { | ||
| ta.oss.options.endpoint.host.should.eql('oss-test.aliyun-inc.com'); | ||
| done(); | ||
| }); | ||
| }); | ||
| it('should throw error when missing endpoint or region', function(done) { | ||
| const app = mm.app({ | ||
| baseDir: 'apps/oss-missing-config', | ||
| }); | ||
| app.on('error', err => { | ||
| err.message.should.equal('[egg-oss] Must set `accessKeyId` and `accessKeySecret` in oss\'s config'); | ||
| done(); | ||
| }); | ||
| }); | ||
| it('should be config correctly', function* () { | ||
| const config = app.config.oss.client; | ||
| config.accessKeyId.should.be.a.String; | ||
| config.accessKeySecret.should.be.a.String; | ||
| config.bucket.should.be.a.String; | ||
| }); | ||
| it('should be injected correctly', function(done) { | ||
| request(app.callback()) | ||
| .get('/') | ||
| .expect({ | ||
| app: true, | ||
| ctx: true, | ||
| putBucket: true, | ||
| }) | ||
| .expect(200, done); | ||
| }); | ||
| it('should upload file stream to oss', function(done) { | ||
| done = pedding(2, done); | ||
| request(app.callback()) | ||
| .get('/uploadtest') | ||
| .expect(function(res) { | ||
| console.log(res.body); | ||
| lastUploadFileName = res.body.name; | ||
| res.body.name.should.be.a.String; | ||
| res.body.url.should.match(/^http:\/\/ali\-oss\-test\-bucket\-test99.oss\-test.aliyun\-inc.com/); | ||
| res.body.res.status.should.equal(200); | ||
| done(); | ||
| }) | ||
| .expect(200, done); | ||
| }); | ||
| it('should upload file stream to oss using custom init oss', function(done) { | ||
| const app = mm.app({ | ||
| baseDir: 'apps/oss-not-init', | ||
| }); | ||
| app.ready(() => { | ||
| done = pedding(2, done); | ||
| request(app.callback()) | ||
| .get('/uploadtest') | ||
| .expect(function(res) { | ||
| lastUploadFileName = res.body.name; | ||
| res.body.name.should.be.a.String; | ||
| res.body.url.should.match(/^http:\/\/ali\-oss\-test\-bucket\-test99.oss\-test.aliyun\-inc.com/); | ||
| res.body.res.status.should.equal(200); | ||
| done(); | ||
| }) | ||
| .expect(200, done); | ||
| }); | ||
| }); | ||
| it('should upload file stream to cluster oss', function(done) { | ||
| done = pedding(2, done); | ||
| app = mm.app({ | ||
| baseDir: 'apps/oss-cluster', | ||
| }); | ||
| app.ready(() => { | ||
| request(app.callback()) | ||
| .get('/uploadtest') | ||
| .expect(function(res) { | ||
| lastUploadFileName = res.body.name; | ||
| res.body.name.should.be.a.String; | ||
| res.body.url.should.match(/^http:\/\/ali\-oss\-test\-bucket\-test99.oss\-test.aliyun\-inc.com/); | ||
| res.body.res.status.should.equal(200); | ||
| done(); | ||
| }) | ||
| .expect(200, done); | ||
| }); | ||
| }); | ||
| }); | ||
| describe('oss in agent', function() { | ||
| let app; | ||
| before(function(done) { | ||
| app = mm.cluster({ | ||
| baseDir: 'apps/oss-agent', | ||
| }); | ||
| app.ready(done); | ||
| }); | ||
| after(function() { | ||
| app.end(); | ||
| }); | ||
| it('should work', function(done) { | ||
| request(app) | ||
| .get('/agent') | ||
| .expect(200, 'OK', done); | ||
| }); | ||
| }); | ||
| describe('oss with clients', () => { | ||
| let app; | ||
| let lastUploadFileName; | ||
| before(function(done) { | ||
| app = mm.app({ | ||
| baseDir: 'apps/oss-clients', | ||
| }); | ||
| app.ready(done); | ||
| }); | ||
| after(function* () { | ||
| if (lastUploadFileName) { | ||
| yield app.oss.get('oss2').delete(lastUploadFileName); | ||
| } | ||
| }); | ||
| it('should upload file stream to oss', function(done) { | ||
| done = pedding(2, done); | ||
| request(app.callback()) | ||
| .get('/uploadtest') | ||
| .expect(function(res) { | ||
| lastUploadFileName = res.body.name; | ||
| res.body.name.should.be.a.String; | ||
| res.body.url.should.match(/^http:\/\/ali\-oss\-test\-bucket\-test99.oss\-test.aliyun\-inc.com/); | ||
| res.body.res.status.should.equal(200); | ||
| done(); | ||
| }) | ||
| .expect(200, done); | ||
| }); | ||
| }); | ||
| }); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1
-50%11
-15.38%188
4.44%0
-100%9097
-99.7%9
-89.53%57
-99.97%2
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated