合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
## 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) }) ```