Vue视频图片的在线存储仓库【七牛云】的使用

文章目录

    • 概要
    • 引入七牛云的依赖
    • 配置七牛云
    • 七牛云的使用
    • 小结

概要

七牛云的使用
官网:点击跳转

引入七牛云的依赖

npm install qiniu-js

配置七牛云

import Vant from 'vant';
Vue.prototype.$qiniu = qiniu

七牛云的使用

  const that = this
        //七牛云配置项②
        const observer = {
          next(res) {
            // 用于展示上传进度
            console.log("七牛运next", res)
          },
          error(err) {
            meassageError("上传失败")
            console.log("七牛运next", err)
          },

          complete(res) {
            lod.close()
            console.log("七牛云complete", res)
            meassageSuccess("上传成功")
            that.userInfo.videoUrl = "https://file.sycup.top/" + res.keyvideoUrl
            that.userInfo.fileVideo = res.hash//保存hash值
          }
        }
        //七牛云配置项①
        const config = {
          useCdnDomain: true,
          region: null,    // 根据地区不同,官网有不同的配置
          concurrentRequestLimit: 1000,
        }
        //设置文件的配置③
        const putExtra = {
          fname: "",
          params: {},
          mimeType: null
        };
        const key = "vod/" + this.userInfo.id + "/" + file.name  //上传文件加入用户id前缀
        getUpToken().then(res => {
          if (res.code === 200) {
            const token = res.data
            const observable = this.$qiniu.upload(file, key, token, putExtra, config)
            const subscription = observable.subscribe(observer) // 上传开始
          }
        })

小结

如果小编的文章对你有所帮助的话,帮忙一键三连续,点赞、关注、收藏,谢谢。

  • 10
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值