如何跑起 js sdk 中的 demo

最近更新时间: 2019-11-07 10:48:58

简介

官方的js sdk中有相关的实例,但是对于不熟悉node的人来说可能有些难以理解,本文来讲述一下


1.使用处理好引入关系的压缩包

http://osp19b87q.bkt.clouddn.com/example.zip

只需要下载后解压缩,打开index.html即可,效果参考 http://jssdk.demo.qiniu.io/

2.使用官方示例中的express来打开

下载地址 https://github.com/qiniu/js-sdk/tree/master/test


进入根目录,执行以下命令

  1. npm install

  2. bower install

  3. grunt

  4. node demo/server.js


建议在执行命令前可以全局安装 bower, grunt

npm install bower -g

npm install grunt -g

使用这个方法需要配置ak和sk

module.exports = { 'AccessKey': '<Your Access Key>', // https://portal.qiniu.com/user/key 'SecretKey': '<Your Secret Key>', 'Bucket': '<Your Bucket Name>', 'Port': 19110, 'UptokenUrl': 'uptoken', 'Domain': '<Your Bucket Name>' // bucket domain eg:http://qiniu-plupload.qiniudn.com/ }; 
以上内容是否对您有帮助?