{"id":13756758,"url":"https://github.com/node-modules/qn","last_synced_at":"2025-06-14T03:07:27.638Z","repository":{"id":10396051,"uuid":"12547493","full_name":"node-modules/qn","owner":"node-modules","description":"Another qiniu http://docs.qiniu.com/api/ API client for Node.js.","archived":false,"fork":false,"pushed_at":"2024-05-28T20:22:19.000Z","size":389,"stargazers_count":274,"open_issues_count":69,"forks_count":34,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-06-12T17:05:37.307Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-modules.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-09-02T19:30:59.000Z","updated_at":"2025-04-19T13:42:25.000Z","dependencies_parsed_at":"2024-05-28T23:26:07.907Z","dependency_job_id":"02f0de85-6e86-4242-92ea-2960a7dd374c","html_url":"https://github.com/node-modules/qn","commit_stats":{"total_commits":77,"total_committers":11,"mean_commits":7.0,"dds":"0.33766233766233766","last_synced_commit":"ce34145903dbdf1dddf40f6d7ae6bf28eb2d9395"},"previous_names":["fengmk2/qn"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/node-modules/qn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fqn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fqn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fqn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fqn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-modules","download_url":"https://codeload.github.com/node-modules/qn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fqn/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259752078,"owners_count":22905972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T11:00:53.254Z","updated_at":"2025-06-14T03:07:27.622Z","avatar_url":"https://github.com/node-modules.png","language":"JavaScript","readme":"qn\n=======\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/qn.svg?style=flat\n[npm-url]: https://npmjs.org/package/qn\n[travis-image]: https://img.shields.io/travis/node-modules/qn.svg?style=flat\n[travis-url]: https://travis-ci.org/node-modules/qn\n[codecov-image]: https://codecov.io/gh/node-modules/qn/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/node-modules/qn\n[david-image]: https://img.shields.io/david/node-modules/qn.svg?style=flat\n[david-url]: https://david-dm.org/node-modules/qn\n[snyk-image]: https://snyk.io/test/npm/qn/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/qn\n[download-image]: https://img.shields.io/npm/dm/qn.svg?style=flat-square\n[download-url]: https://npmjs.org/package/qn\n\n\nAnother [qiniu](http://docs.qiniu.com/api/) API client for Node.js.\n\n## Install\n\n```bash\n$ npm install qn --save\n```\n\n## Usage\n\n### Upload\n\n```js\nvar qn = require('qn');\n\nvar client = qn.create({\n  accessKey: 'your access key',\n  secretKey: 'your secret key',\n  bucket: 'your bucket name',\n  origin: 'http://{bucket}.u.qiniudn.com',\n  // timeout: 3600000, // default rpc timeout: one hour, optional\n  // if your app outside of China, please set `uploadURL` to `http://up.qiniug.com/`\n  // uploadURL: 'http://up.qiniu.com/',\n});\n\n// upload a file with custom key\nclient.uploadFile(filepath, {key: 'qn/lib/client.js'}, function (err, result) {\n  console.log(result);\n  // {\n  //   hash: 'FhGbwBlFASLrZp2d16Am2bP5A9Ut',\n  //   key: 'qn/lib/client.js',\n  //   url: 'http://qtestbucket.qiniudn.com/qn/lib/client.js'\n  //   \"x:ctime\": \"1378150371\",\n  //   \"x:filename\": \"client.js\",\n  //   \"x:mtime\": \"1378150359\",\n  //   \"x:size\": \"21944\",\n  // }\n});\n\n// upload a stream\nclient.upload(fs.createReadStream(filepath), function (err, result) {\n  console.log(result);\n  // {\n  //   hash: 'FvnDEnGu6pjzxxxc5d6IlNMrbDnH',\n  //   key: 'FvnDEnGu6pjzxxxc5d6IlNMrbDnH',\n  //   url: 'http://qtestbucket.qiniudn.com/FvnDEnGu6pjzxxxc5d6IlNMrbDnH',\n  //   \"x:filename\": \"foo.txt\",\n  // }\n});\n\n// you also can upload a string or Buffer directly\nclient.upload('哈哈', {key: 'haha.txt'}, function (err, result) {\n  console.log(result);\n  // hash: 'FptOdeKmWhcYHUXa5YmNZxJC934B',\n  // key: 'haha.txt',\n  // url: 'http://qtestbucket.qiniudn.com/haha.txt',\n});\n\n// xVariables\nclient.upload(filepath, { 'x:foo': 'bar' }, function (err, result) {\n  console.log(result);\n  // hash: 'FptOdeKmWhcYHUXa5YmNZxJC934B',\n  // key: 'foobar.txt',\n  // url: 'http://qtestbucket.qiniudn.com/foobar.txt',\n  // x:foo: 'bar'\n});\n```\n\n### uploadToken\n\n```\nvar token = client.uploadToken();\n```\n\nor with options\n\n- scope\n- deadline\n\n````\nvar token = client.uploadToken({\n  deadline: utility.timestamp() + 10\n});\n```\n\n### Download\n\n```js\n// download to Buffer\nclient.download('foo.txt', function (err, content, res) {\n  // content is a Buffer instance.\n  console.log('content size: %d', content.length);\n});\n\n// save as url\nvar url = client.saveAsURL('qn/test/dl/foo.txt', '哈哈foo.txt');\n// http://qtestbucket.qiniudn.com/qn/test/dl/foo.txt?download/%E5%93%88%E5%93%88foo.txt\n```\n\n### RS Operations\n\n```js\n// stat\nclient.stat('foo.txt', function (err, stat) {\n  console.log(stat);\n  // fsize: 8,\n  // hash: 'FvnDEnGu6pjzxxxc5d6IlNMrbDnH',\n  // mimeType: 'text/plain',\n  // putTime: 13783134309588504\n});\n\n// move\nclient.move('foo.txt', 'qn/bar.txt', function (err) {\n\n});\n\n// copy\nclient.copy('foo.txt', 'qn/bar.txt', function (err) {\n\n});\n\n// delete\nclient.delete('foo.txt', function (err) {\n\n});\n\n// list\nclient.list('/', function (err, result) {\n  console.log(result);\n  // marker: 'eyJjIjowLCJrIjoicW4vYmlnLnR4dCJ9'\n  // items: [\n  //   {\n  //     fsize: 21944,\n  //     putTime: 13783144546186030,\n  //     key: 'qn/logo.png',\n  //     hash: 'FvzqAF1oWlYgQ9t62k_xn_mzZ1Ki',\n  //     mimeType: 'image/png'\n  //   }, ...\n  // ]\n});\n```\n\n### Image operations\n\n```js\n// imageInfo\nclient.imageInfo('qn/logo.png', function (err, info) {\n  console.log(info);\n  // { format: 'png', width: 190, height: 150, colorModel: 'nrgba' }\n});\n\n// exif\nclient.exif('qn/logo.png', function (err, exif) {\n\n});\n\n// imageView\nvar url = client.imageView('qn/logo.png', {mode: 1, width: 100, height: 100, q: 50, format: 'png'});\n// http://qtestbucket.qiniudn.com/qn/logo.png?imageView/1/w/100/h/100/q/50/format/png\n\n// imageMogr\nvar url = client.imageMogr('qn/fixtures/gogopher.jpg', {\n  thumbnail: '!50p',\n  gravity: 'NorthWest',\n  quality: 50,\n  rotate: -50,\n  format: 'gif'\n});\n// http://qtestbucket.qiniudn.com/qn/fixtures/gogopher.jpg?imageMogr/v2/auto-orient/thumbnail/!50p/gravity/NorthWest/quality/50/rotate/-50/format/gif\n\n// watermark\nvar url = client.watermark('qn/logo.png', {\n  mode: 2,\n  text: 'Node.js 哈哈',\n  font: '宋体',\n  fontsize: 500,\n  fill: 'red',\n  dissolve: 100,\n  gravity: 'SouthEast',\n  dx: 100,\n  dy: 90\n});\n// http://qtestbucket.qiniudn.com/qn/fixtures/gogopher.jpg?watermark/2/text/Tm9kZS5qcyDlk4jlk4g=/font/5a6L5L2T/fontsize/500/fill/cmVk/dissolve/100/gravity/SouthEast/dx/100/dy/90\n```\n\n### Document Operations\n\n```js\n// markdown to html\nvar url = client.md2html('qn/test/fixtures/readme.md', {\n  css: 'http://qtestbucket.qiniudn.com/qn/test/fixtures/github.css'\n});\n// http://qtestbucket.qiniudn.com/qn/test/fixtures/readme.md?md2html/0/css/aHR0cDovL3F0ZXN0YnVja2V0LnFpbml1ZG4uY29tL3FuL3Rlc3QvZml4dHVyZXMvZ2l0aHViLmNzcw==\n```\n\n## TODO\n\n* [x] RS Operations\n* [ ] HTTP Keep-alive\n* [x] Image Operations\n* [ ] Media Operations\n* [x] Doc Operations\n* [ ] Pipeline Operations\n* [x] QR code Operations\n\n## License\n\n[MIT](LICENSE.txt)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Fqn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-modules%2Fqn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Fqn/lists"}