Qiniu React Native SDK ,A pure javascript implementation
Switch branches/tags
Nothing to show
Clone or download
Latest commit e985dd5 Aug 7, 2017
Permalink
Failed to load latest commit information.
core AddRpcSendOnError Aug 2, 2017
.gitignore rm useless log Jun 24, 2016
LICENSE Initial commit Apr 12, 2016
README.md Update README.md Jan 11, 2017
index.js es6 style Jun 22, 2016
package.json upgrade version Jan 11, 2017

README.md

React Native Qiniu SDK

纯JavaScript实现的Qiniu SDK,

##安装 npm i react-native-qiniu --save

##使用方法

import Qiniu,{Auth,ImgOps,Conf,Rs,Rpc} from 'react-native-qiniu';
Conf.ACCESS_KEY = <AK>
Conf.SECRET_KEY = <SK>
//强烈不建议在客户端保存 AK 和 SK ,反编译后 hacker 获取到可以对你的资源为所欲为,建议通过安全渠道从服务器端获取。

//upload file to Qiniu
var putPolicy = new Auth.PutPolicy2(
    {scope: "<Bucket>:<Key>"}
);
var uptoken = putPolicy.token();
let formInput = {
    key : "<Key>",
    // formInput对象如何配置请参考七牛官方文档“直传文件”一节
}
Rpc.uploadFile(<LOCAL_URL>, uptoken, formInput);

//download private file
var getPolicy = new Auth.GetPolicy();
let url = getPolicy.makeRequest('http://7xp19y.com2.z0.glb.qiniucdn.com/5.jpg');
//fetch from this url

//image sync operation
var imgInfo = new ImgOps.ImageView(1,100,200);
let url = imgInfo.makeRequest('http://7xoaqn.com2.z0.glb.qiniucdn.com/16704/6806d20a359f43c88f1cb3c59980e5ef');
//fetch from this url

//image info 
var self = this;
var imgInfo = new ImgOps.ImageInfo();
let url = imgInfo.makeRequest('http://7xoaqn.com2.z0.glb.qiniucdn.com/16704/6806d20a359f43c88f1cb3c59980e5ef');
fetch(url).then((response) => {
      return response.text();
    }).then((responseText) => {
      self.setState({info: responseText});
    }).catch((error) => {
      console.warn(error);
    });

//resource operation
//stat info
var self = this;
Rs.stat(<BUCKET>, <KEY)
        .then((response) => response.text())
        .then((responseText) => {
          self.setState({info: responseText});
        })
        .catch((error) => {
          console.warn(error);
        });

##进行中

RoadMap

##Release Note ###0.1.0

  • 上传文件
  • 私有库中文件下载功能
  • Image Ops
  • 资源管理

###0.1.1

  • 重构 upload 方法 (CaveyChan)

###0.2.0

  • es6 style

###0.3.0

  • 增加 progress callback

##Contributor

  • CaveyChan
  • laukey
  • cdmalcl

##相关文章

React Native 文件上传 和 react-native-qiniu