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) // 上传开始
          }
        })

小结

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

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-29 11:24:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-29 11:24:03       101 阅读
  3. 在Django里面运行非项目文件

    2024-01-29 11:24:03       82 阅读
  4. Python语言-面向对象

    2024-01-29 11:24:03       91 阅读

热门阅读

  1. 前端VUE导出excel多sheet,适用单多导出

    2024-01-29 11:24:03       63 阅读
  2. C语言之猜凶手

    2024-01-29 11:24:03       55 阅读
  3. 将文件以指定格式存储~BMP~C的实现~FAT32格式

    2024-01-29 11:24:03       48 阅读
  4. js有哪些内置对象?

    2024-01-29 11:24:03       48 阅读
  5. 【前端基础--5】

    2024-01-29 11:24:03       43 阅读
  6. ubuntu 查看版本号、查看内核版本号

    2024-01-29 11:24:03       52 阅读
  7. Ubuntu18.04录音声音降噪

    2024-01-29 11:24:03       60 阅读
  8. python元组切片

    2024-01-29 11:24:03       54 阅读
  9. 基于stm32的伸缩晒衣架的设计

    2024-01-29 11:24:03       49 阅读