{"id":13755185,"url":"https://github.com/upyun/wechat-sdk","last_synced_at":"2026-04-01T18:31:40.118Z","repository":{"id":55944797,"uuid":"82655171","full_name":"upyun/wechat-sdk","owner":"upyun","description":"又拍云微信小程序 SDK","archived":false,"fork":false,"pushed_at":"2020-11-20T17:53:20.000Z","size":60,"stargazers_count":69,"open_issues_count":3,"forks_count":27,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-08-24T05:01:23.897Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/upyun.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-21T08:28:56.000Z","updated_at":"2024-08-24T05:01:23.898Z","dependencies_parsed_at":"2022-08-15T10:00:56.135Z","dependency_job_id":null,"html_url":"https://github.com/upyun/wechat-sdk","commit_stats":null,"previous_names":["upyun/upyun-wxapp-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upyun%2Fwechat-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upyun%2Fwechat-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upyun%2Fwechat-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upyun%2Fwechat-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/upyun","download_url":"https://codeload.github.com/upyun/wechat-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253346490,"owners_count":21894264,"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-03T10:00:48.384Z","updated_at":"2026-04-01T18:31:40.069Z","avatar_url":"https://github.com/upyun.png","language":"JavaScript","funding_links":[],"categories":["实用库"],"sub_categories":[],"readme":"# 又拍云微信小程序 SDK\n\n[又拍云](https://upyun.com) [微信小程序 SDK](http://docs.upyun.com/api/small_program/)，帮助你在存储空间、资源存放、访问加速、资源处理等方面进行大幅优化，为微信小程序提供扩容、加速解决方案。\n\n## 使用\n\n使用方式可以参考 demo\n\n1. 登录微信小程序账户并配置 uploadFile 合法域名为 https://v0.api.upyun.com\n2. 软链 upyun-wxapp-sdk.js 到微信小程序项目\n3. 通过 `require` 引入 `Upyun` 类，并初始化一个实例\n4. 调用 `upyun.upload` 方法上传文件\n\n\n## 运行 Demo\n\n下载微信[小程序开发工具](https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/devtools.html)\n\n增加 demo 目录为新项目\n\n![add-project](assets/add-project.png)\n\n运行服务器进程\n\n    npm run demo\n\n## 接口\n\n`Upyun`\n\n* bucket: 空间名\n* operator: 操作员\n* getSignatureUrl: 计算 `signature` 的服务器接口地址\n\n示例\n\n```js\nconst upyun = new Upyun({\n  bucket: 'sdkimg',\n  operator: 'tester',\n  getSignatureUrl: 'http://localhost:8080',\n})\n```\n\n`Upyun.prototype.upload`\n\n* remotePath 在又拍云存储的文件路径\n* localPath 本地文件路径\n* success 接口调用成功的回调函数\n* fail 接口调用失败的回调函数\n* complete 接口调用结束的回调函数（调用成功、失败都会执行）\n\n```js\nupyun.upload({\n  localPath: imageSrc,\n  remotePath: '/wxapp/demo',\n  success: function(res) {\n  },\n  fail: function({errMsg}) {\n  },\n})\n```\n\n## 服务器接口\n\n使用又拍云微信小程序 SDK 需要实现一个在服务器进行签名的接口，并将该接口地址作为 `getSignatureUrl` 传入构造函数，\n\n该接口接受 `GET` 请求，并接受一个参数 `data`，计算并返回带有 `signature` 字段的响应\n\n`signature` 的计算公式是\n\n    Base64 (HMAC-SHA1 (\u003cmd5_password\u003e, \u003cdata\u003e)\n\n其中，`md5_password` 是操作员密码的 MD5 值\n\n## 相关链接\n\n* [微信小程序 uploadFile 接口](https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-file.html#wxuploadfileobject)\n* [又拍云表单 API](https://docs.upyun.com/api/form_api/)\n* [又拍云表单提交签名算法](http://docs.upyun.com/api/authorization/#body)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupyun%2Fwechat-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fupyun%2Fwechat-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupyun%2Fwechat-sdk/lists"}