zoukankan      html  css  js  c++  java
  • Vue 七牛云上传文件

    npm install qiniu-js

    所用页面

    const qiniu = require('qiniu-js')
    // or
    import * as qiniu from 'qiniu-js'
        upLoad() {
          let that = this;
          let fileName = this.imgData[0].name;
          let key = new Date().getTime(); // 上传ket
          let token = that.uptoken;
          const putExtra = {
            fname: "",
            params: {},
            mimeType: null
          };
          const config = {
            region:'',
            chunkSize:10,
            forceDirect:false,
          };
          const headers = qiniu.getHeadersForChunkUpload(that.uptoken);
          const observable = qiniu.upload(
            this.imgData[0].raw,//文件数组
            key,
            token,
            putExtra,
            config
          );const observer = {
            next: response => {
              if(Math.floor(response.total.percent)>=100){
                // clearInterval(that.Interval)
                console.log(Math.floor(response.total.percent))
              }// console.log(response);
              // 上传进度'+Math.floor(response.total.percent)+'%'
            },
            error: err => {
              // 失败
              this.$message.error("上传失败" + err.message);
            },
            complete: response => {
              console.log(response);
            }
          };
          observable.subscribe(observer); // 上传开始
        },

    官方文档地址

    https://developer.qiniu.com/kodo/sdk/javascript

  • 相关阅读:
    统计代码行数
    梯度下降算法
    multiplot 安装与配置
    ros 源码安装
    cmake 指定gcc/g++版本
    python 科学计算基础库安装
    协方差矩阵的含义
    pysvn 相关
    void 0与undefined
    BEM规范
  • 原文地址:https://www.cnblogs.com/wangshishuai/p/14453298.html
Copyright © 2011-2022 走看看