How to use the qiniu-js.region function in qiniu-js

To help you get started, we’ve selected a few qiniu-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mdnice / markdown-nice / src / utils / imageHosting.js View on Github external
base64Reader.onload = (e) => {
      const urlData = e.target.result;
      const base64 = urlData.split(",").pop();
      const fileType = urlData
        .split(";")
        .shift()
        .split(":")
        .pop();

      // base64转blob
      const blob = toBlob(base64, fileType);

      const conf = {
        useCdnDomain: true,
        region: qiniu.region[config.region], // 区域
      };

      const putExtra = {
        fname: "",
        params: {},
        mimeType: [] || null,
      };

      const OSSName = getOSSName(file.name, namespace);

      // 这里第一个参数的形式是blob
      const imageObservable = qiniu.upload(blob, OSSName, token, putExtra, conf);

      // 上传成功后回调
      const complete = (response) => {
        // console.log(response);
github nieyao / qm_lesson / react / react-juejin / client / src / components / upload / index.js View on Github external
uploadFn = async () => {
    let response = await API.getToken();
    let { baseUrl, token } = response.data;
    let files = this.refs.upload.files;
    console.log(files);
    // 是否是一张照片?
    // 七牛 
    if (!this.imageVerify()) return;
    let putExtra = {
      fname: '',
      params: {},
      mimeType: ['image/png','image/jpeg','image/gif']
    };
    let config = {
      region: qiniu.region.z0
    };

    let key = new Date().getTime() + files[0].name;
    let observable = qiniu.upload(files[0], key, token, putExtra, config)
    let observer = {
      compelete: (res) => {
        let imgUrl = baseUrl + '/' + res.key;
        console.log(imgUrl);
        this.props.successCb(imgUrl);
      },
      error: (err) => {
        notification.error({
          message: err
        })
      }
    }
github zhoushaw / Instagram / client / src / components / upload / index.js View on Github external
let response = await API.getToken()
        let {baseUrl, token} = response.data
        let files = this.refs.upload.files

        // 校验图片
        if (!this.imageVerify) return


        var putExtra = {
            fname: "",
            params: {},
            mimeType: ["image/png", "image/jpeg", "image/gif"]
        };

        var config = {
            region: qiniu.region.z0
        };
        
        // 文件名
        let key = new Date().getTime() + files[0].name;
        var observable = qiniu.upload(files[0], key, token, putExtra, config)

        var observer = {
            next: (res) => {
              // ...
            },
            error: (err) => {
                notification.error({
                    message: err
                })
            }, 
            complete: (res) => {
github GavinZhuLei / vue-form-making / src / components / Upload / index.vue View on Github external
uplaodAction2 (res, file, key) {
      const _this = this
      const observable = qiniu.upload(file, key, this.token, {
        fname: key,
        mimeType: []
      }, {
        useCdnDomain: true,
        region: qiniu.region.z2
      })
      observable.subscribe({
        next (res) {
          _this.$set(_this.fileList[_this.fileList.findIndex(item => item.key === key)], 'percent', parseInt(res.total.percent))
          
        },
        error (err) {
          _this.$set(_this.fileList, _this.fileList.findIndex(item => item.key === key), {
            ..._this.fileList[_this.fileList.findIndex(item => item.key === key)],
            status: 'error'
          })
          _this.fileList.splice(_this.fileList.findIndex(item => item.key === key), 1)
        },
        complete (res) {
          _this.$set(_this.fileList, _this.fileList.findIndex(item => item.key === key), {
            ..._this.fileList[_this.fileList.findIndex(item => item.key === key)],

qiniu-js

Qiniu browser upload sdk

MIT
Latest version published 3 months ago

Package Health Score

81 / 100
Full package analysis

Popular qiniu-js functions