Giter Club home page Giter Club logo

edpx-bos's Introduction

edpx-bos

Usage

edp

edp bos a.js bos://<bucket>/a.js

edp bos dir bos://<bucket>/dir

输出形如:

edp INFO endpoint url: http://bos.nj.bpc.baidu.com/<bucket>/a.js
edp INFO cdn url:      http://boscdn.bpc.baidu.com/<bucket>/a.js

endpoint url根据配置的endpoint直接拼接而成,重复上传后会文件内容会实时更新 cdn url根据OP的映射关系生成,经过cdn分配,重复上传后不一定会更新,也不确定什么时候会更新

api

var bos = require('edpx-bos');

var ak = '';
var sk = '';
var endpoint = '';
var maxSize = 10 * 1024; // 10K
var autoUri = false;

// 上传文件
var sdk = new bos.sdk.BaiduObjectStorage(ak, sk, endpoint, maxSize, autoUri);

var def = sdk.upload(bucket, localFile);
def.done(function (url) {
    console.log(url);
});
def.fail(function (e) {
    console.error(e);
});

// 上传目录
var def = sdk.upload(bucket, localDir);
def.done(function (result) {
  /** Array.<{item: string, url: string}> */
  result.success;

  /** Array.<{item: string, error: string}>*/
  result.failure;
});

// def不会进入rejected的状态,不需要fail的处理函数.
// done.fail(function(){});

edpx-bos's People

Contributors

easonyq avatar leeight avatar pengxing avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

easonyq

edpx-bos's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.