🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## node对接七牛获取token 七牛NodeJs SDK https://developer.qiniu.com/kodo/sdk/1289/nodejs qiniuToken.js ``` // 七牛依赖 const qiniu = require("qiniu") // ak let accessKey = 'ZC0_eBtUmOeuwNDSEvmrOkFJtq8Ffb...' // sk let secretKey = 'mDlCsAplbvLsnXITyDhHw0NpEa....' let mac = new qiniu.auth.digest.Mac(accessKey, secretKey) // 配置 let options = { scope: 'images' } let putPolicy = new qiniu.rs.PutPolicy(options) let token = putPolicy.uploadToken(mac) exports.token = token ``` server.js ``` var express = require('express') var app = express() var qiniuToken = require('./qiniuToken') app.get('/getToken', function (req, res) { res.set('Access-Control-Allow-Origin', '*') res.send(qiniuToken.token) }) var server = app.listen(3000, function () { var port = server.address().port console.log('端口:http://127.0.0.1:%s', port) }) ```