websdk上传阿里云视频完整教程

news2024/11/17 9:36:31

批量上传视频到阿里云

这段时间项目里有一个上传视频到阿里云的功能是我来负责写的,之前一直没有写过这种功能,感觉很难的亚子,但是后来仔细研究了一遍发现也没想象中那么难,最后经过不懈的努力也算是搞出来了哈哈哈,开心坏我了。搞出这个功能真的也是学习到了很多东西,所以就来这里记录一下啦。也有同样需求的兄弟姐妹们希望可以帮到你们一点点嘻嘻,如果有更简单轻便的方法或哪里需要改进的地方也请大家多多指教呦

我用的就是 vue+element 写的

阿里云给我们提供了客户端上传的SDK
使用JavaScript上传SDK.
这个页面从头到尾过一遍就能了解个大概了在这里插入图片描述
细心的小伙伴在下载SDK的时候就会发现有demo可以看哈哈哈
在这里插入图片描述
阿里云真的绝绝子啊!!! 直接有代码可以抄,这还不Ctrl+C / Ctrl+V 安排上
让后台给出 获取上传凭证和地址 接口 一对接,ok,功能完成!!!

哈哈哈哈,其实没这么简单,
我开始真单纯的以为就这样就结束了,然而被告知需要批量上传的时候我都石化了,阿里云也没批量上传的代码让我来抄,
害,然而又有什么办法呢,写呗,
因为我写的页面就是纯单个上传的那种,批量删除要显示成列表形式的,所以之前写的页面几乎不能用了,然后我就只能重新搞一个页面再写了,当然上传方法还是用的阿里云上传的那个方法
因为单个上传的页面代码啥的都已经让我给删了所以下面就直接分享批量上传的代码和页面了

首先来看一下上传视频的页面吧
在这里插入图片描述
demo里面那些按钮还是能继续用的

然后看代码
html
在这里插入图片描述
页面样式这些感觉自己公司的要求或者自己的喜好来写就好了

变量
在这里插入图片描述

JS

// 添加视频文件
    fileChange (e) {
      console.log(e.target.files);
      this.files = e.target.files
      if (!this.files) {
        return this.$message.warning("选择需要上传的视频")
      }
      var userData = '{"Vod":{}}'
      if (this.uploader) {
        this.uploader.stopUpload()
        this.authProgress = 0
        this.statusText = ""
      }
      this.uploader = this.createUploader()
      for (let i = 0; i < this.files.length; i++) {
        let url = URL.createObjectURL(this.files[i]);
        let audioElement = new Audio(url);
        setTimeout(() => {
          this.videomsg = {
            title: this.files[i].name.substring(0, this.files[i].name.indexOf('.')),
            fileName: this.files[i].name,
            type: 0,
            size: this.files[i].size,
            seconds: audioElement.duration,
          }
          //因为 获取上传地址和凭证接口需要很多参数,而这样列表形式的参数传的时候不太好搞,我在这里直接给他加到file里面了,一会再上传的方法里可以直接获取当前上传文件的所有参数
          this.files[i].obj = this.videomsg
          //addFile是添加文件的方法(这些null,null,null我的不知道什么鬼,一度尝试用他们来把参数加进去可惜都不行,前两个是报错,后一个可以没报错,传进去是在一个object对象里面,可以我捣鼓了半天还是不行)
          this.uploader.addFile(this.files[i], null, null, null, userData)
      <span class="token keyword">this</span><span class="token punctuation">.</span>videoList<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>videomsg<span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">500</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>uploadDisabled <span class="token operator">=</span> <span class="token boolean">false</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>pauseDisabled <span class="token operator">=</span> <span class="token boolean">true</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>resumeDisabled <span class="token operator">=</span> <span class="token boolean">true</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>

下面这段代码跟上面的这一段是一个方法,只是变更了一下传递参数的方式,因项目需求后期修改了一下

// 添加视频文件
fileChange (e) {
      if (!e.target.files) {
        return this.$message.warning("选择需要上传的视频")
      }
      var userData = '{"Vod":{}}'
      if (this.uploader) {
        this.uploader.stopUpload()
        this.authProgress = 0
        this.statusText = ""
      }
      this.uploader = this.createUploader()
      e.target.files.forEach((item, index) => {
        let url = URL.createObjectURL(item);
        let audioElement = new Audio(url);
        setTimeout(() => {
          this.videomsg = {
            title: item.name.substring(0, item.name.indexOf('.')),
            fileName: item.name,
            type: 0,
            size: item.size,
            seconds: audioElement.duration,
          }
          this.compare(this.videoList, this.videomsg)
          this.videoList.forEach(item => {
            if (!item.tagItems) {
              item.tagItems = []
            }
          })
          item.obj = this.videomsg
          this.files.push(item)
        }, 500)
      })
      setTimeout(() => {
        for (let i = 0; i < this.files.length; i++) {
          this.uploader.addFile(this.files[i], null, null, null, userData)
        }
      }, 600);
      this.uploadDisabled = false
      this.pauseDisabled = true
      this.resumeDisabled = true
    },

 
 

在这里插入图片描述

createUploader () {
      let self = this
      let uploader = new AliyunUpload.Vod({
        timeout: 90000,//这个是上传失效时间
        partSize: 1048576,
        parallel: self.files.length,
        retryCount: 3,
        retryDuration: 2,
        region: 'cn-beijing',//填写自己阿里云服务器的region
        userId: '275487806961125824',
        // 添加文件成功
        addFileSuccess: function (uploadInfo) {
          self.uploadDisabled = false
          self.resumeDisabled = false
          self.clearDisabled = false
          self.statusText = '添加文件成功,等待上传...'
      <span class="token comment">// self.updateState = true</span>
      <span class="token comment">// self.updateText = '文件已添加成功,还未上传,关闭窗口后之前操作都将失效,是否确认关闭?'</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// 开始上传</span>
    <span class="token function-variable function">onUploadstarted</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span>uploadInfo<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
      <span class="token comment">// var list = self.uploader.listFiles()</span>
      <span class="token comment">// for (let i = 0; i &lt; list.length; i++) {<!-- --></span>
      <span class="token comment">//   console.log("上传列表", list[i]);</span>
      <span class="token comment">// }</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>uploadInfo<span class="token punctuation">.</span>videoId<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">"获取上传凭证"</span><span class="token punctuation">,</span> uploadInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//这个调后台给的 获取上传地址和凭证接口</span>
        <span class="token function">addMediaResource</span><span class="token punctuation">(</span>uploadInfo<span class="token punctuation">.</span>file<span class="token punctuation">.</span>obj<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{<!-- --></span>
          <span class="token comment">// console.log(result);</span>
          <span class="token keyword">let</span> uploadAuth <span class="token operator">=</span> result<span class="token punctuation">.</span>uploadSecurity<span class="token punctuation">.</span>uploadAuth
          <span class="token keyword">let</span> uploadAddress <span class="token operator">=</span> result<span class="token punctuation">.</span>uploadSecurity<span class="token punctuation">.</span>uploadAddress
          <span class="token keyword">let</span> videoId <span class="token operator">=</span> result<span class="token punctuation">.</span>uploadSecurity<span class="token punctuation">.</span>videoId
          <span class="token comment">//这个是阿里云上传的方法(阿里云会自定依次上传你选择的多个视频的,不需要循环或者什么的)</span>
          self<span class="token punctuation">.</span>uploader<span class="token punctuation">.</span><span class="token function">setUploadAuthAndAddress</span><span class="token punctuation">(</span>uploadInfo<span class="token punctuation">,</span> uploadAuth<span class="token punctuation">,</span> uploadAddress<span class="token punctuation">,</span> videoId<span class="token punctuation">)</span><span class="token punctuation">;</span>
          self<span class="token punctuation">.</span>uploadIds<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>result<span class="token punctuation">.</span>id<span class="token punctuation">)</span>
        <span class="token comment">//因后台上传会很占用带宽,所以没用后台的上传接口</span>
        <span class="token comment">//让后端给一个更新阿里云数据的接口,上传结束后在列表页面调用一下就ok了(不是指上传列表哦)</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token punctuation">(</span>err<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{<!-- --></span>
          <span class="token keyword">let</span> fileName <span class="token operator">=</span> err<span class="token punctuation">.</span>message<span class="token punctuation">.</span><span class="token function">slice</span><span class="token punctuation">(</span><span class="token number">9</span><span class="token punctuation">)</span>
          <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> self<span class="token punctuation">.</span>videoList<span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>fileName <span class="token operator">==</span> self<span class="token punctuation">.</span>videoList<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">.</span>title<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
              self<span class="token punctuation">.</span><span class="token function">delvideo</span><span class="token punctuation">(</span>self<span class="token punctuation">.</span>videoList<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">,</span> i<span class="token punctuation">)</span>
            <span class="token punctuation">}</span>
          <span class="token punctuation">}</span>
          <span class="token keyword">const</span> h <span class="token operator">=</span> self<span class="token punctuation">.</span>$createElement<span class="token punctuation">;</span>
          self<span class="token punctuation">.</span><span class="token function">$notify</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
            title<span class="token operator">:</span> <span class="token string">'提示'</span><span class="token punctuation">,</span>
            message<span class="token operator">:</span> <span class="token function">h</span><span class="token punctuation">(</span><span class="token string">'i'</span><span class="token punctuation">,</span> <span class="token punctuation">{<!-- --></span> style<span class="token operator">:</span> <span class="token string">'color: teal'</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token string">'列表已存在'</span> <span class="token operator">+</span> fileName <span class="token operator">+</span> <span class="token string">'文件,无法再次上传,点击 恢复上传 按钮继续上传其他文件'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            duration<span class="token operator">:</span> <span class="token number">0</span>
          <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          self<span class="token punctuation">.</span>uploader<span class="token punctuation">.</span><span class="token function">stopUpload</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
          self<span class="token punctuation">.</span>authProgress <span class="token operator">=</span> <span class="token number">0</span>
          self<span class="token punctuation">.</span>statusText <span class="token operator">=</span> <span class="token string">""</span>
          self<span class="token punctuation">.</span>pauseDisabled <span class="token operator">=</span> <span class="token boolean">true</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
        <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">"刷新上传凭证"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 如果videoId有值,根据videoId刷新上传凭证(https://help.aliyun.com/document_detail/55408.html)</span>
        <span class="token function">refreshMediaResource</span><span class="token punctuation">(</span>uploadInfo<span class="token punctuation">.</span>videoId<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{<!-- --></span>
          <span class="token keyword">let</span> uploadAuth <span class="token operator">=</span> result<span class="token punctuation">.</span>uploadAuth
          <span class="token keyword">let</span> uploadAddress <span class="token operator">=</span> result<span class="token punctuation">.</span>uploadAddress
          <span class="token keyword">let</span> videoId <span class="token operator">=</span> result<span class="token punctuation">.</span>videoId
          self<span class="token punctuation">.</span>uploader<span class="token punctuation">.</span><span class="token function">setUploadAuthAndAddress</span><span class="token punctuation">(</span>uploadInfo<span class="token punctuation">,</span> uploadAuth<span class="token punctuation">,</span> uploadAddress<span class="token punctuation">,</span> videoId<span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token punctuation">(</span>err<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{<!-- --></span>
          <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>err<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// 文件上传成功</span>
    <span class="token function-variable function">onUploadSucceed</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span>uploadInfo<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
      <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'文件上传成功'</span><span class="token punctuation">,</span> uploadInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token comment">// console.log("onUploadSucceed: " + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object)</span>
      self<span class="token punctuation">.</span>statusText <span class="token operator">=</span> <span class="token string">'文件上传成功!'</span>
      self<span class="token punctuation">.</span>file <span class="token operator">=</span> uploadInfo<span class="token punctuation">.</span>file<span class="token punctuation">.</span>name
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// 文件上传失败</span>
    <span class="token function-variable function">onUploadFailed</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span>uploadInfo<span class="token punctuation">,</span> code<span class="token punctuation">,</span> message<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
      <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'文件上传失败'</span><span class="token punctuation">,</span> uploadInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token comment">// console.log("onUploadFailed: file:" + uploadInfo.file.name + ",code:" + code + ", message:" + message)</span>
      self<span class="token punctuation">.</span>statusText <span class="token operator">=</span> <span class="token string">'文件上传失败!'</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// 取消文件上传</span>
    <span class="token function-variable function">onUploadCanceled</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span>uploadInfo<span class="token punctuation">,</span> code<span class="token punctuation">,</span> message<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
      <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'文件已暂停上传'</span><span class="token punctuation">,</span> uploadInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token comment">// console.log("Canceled file: " + uploadInfo.file.name + ", code: " + code + ", message:" + message)</span>
      self<span class="token punctuation">.</span>statusText <span class="token operator">=</span> <span class="token string">'文件已暂停上传'</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// 文件上传进度,单位:字节,可以在这个函数中拿到上传进度并显示在页面上</span>
    <span class="token function-variable function">onUploadProgress</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span>uploadInfo<span class="token punctuation">,</span> totalSize<span class="token punctuation">,</span> progress<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
      <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'文件上传中'</span><span class="token punctuation">,</span> uploadInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token comment">// console.log("onUploadProgress:file:" + uploadInfo.file.name + ", fileSize:" + totalSize + ", percent:" + Math.ceil(progress * 100) + "%")</span>
      <span class="token keyword">let</span> progressPercent <span class="token operator">=</span> Math<span class="token punctuation">.</span><span class="token function">ceil</span><span class="token punctuation">(</span>progress <span class="token operator">*</span> <span class="token number">100</span><span class="token punctuation">)</span>
      self<span class="token punctuation">.</span>authProgress <span class="token operator">=</span> progressPercent
      self<span class="token punctuation">.</span>file <span class="token operator">=</span> uploadInfo<span class="token punctuation">.</span>file<span class="token punctuation">.</span>name
      self<span class="token punctuation">.</span>statusText <span class="token operator">=</span> <span class="token string">'文件上传中'</span>

      self<span class="token punctuation">.</span>updateState <span class="token operator">=</span> <span class="token boolean">true</span>
      self<span class="token punctuation">.</span>updateText <span class="token operator">=</span> <span class="token string">'文件上传中,关闭窗口上传文件将会出现异常,请勿关闭窗口!!!'</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// 上传凭证超时</span>
    <span class="token function-variable function">onUploadTokenExpired</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span>uploadInfo<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
      <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'文件超时'</span><span class="token punctuation">,</span> uploadInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token comment">// 上传大文件超时, 如果是上传方式一即根据 UploadAuth 上传时</span>
      <span class="token comment">// 需要根据 uploadInfo.videoId 调用刷新视频上传凭证接口(https://help.aliyun.com/document_detail/55408.html)重新获取 UploadAuth</span>
      <span class="token comment">// 然后调用 resumeUploadWithAuth 方法</span>
      <span class="token function">refreshMediaResource</span><span class="token punctuation">(</span>uploadInfo<span class="token punctuation">.</span>videoId<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">let</span> uploadAuth <span class="token operator">=</span> data<span class="token punctuation">.</span>UploadAuth
        uploader<span class="token punctuation">.</span><span class="token function">resumeUploadWithAuth</span><span class="token punctuation">(</span>uploadAuth<span class="token punctuation">)</span>
      <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token punctuation">(</span>err<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{<!-- --></span>
        <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>err<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      self<span class="token punctuation">.</span>statusText <span class="token operator">=</span> <span class="token string">'文件超时...'</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// 全部文件上传结束</span>
    <span class="token function-variable function">onUploadEnd</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span>uploadInfo<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
      <span class="token builtin">console</span><span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'文件上传完毕uploaded all the files'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      self<span class="token punctuation">.</span>statusText <span class="token operator">=</span> <span class="token string">'文件上传完毕'</span>
      self<span class="token punctuation">.</span><span class="token function">$emit</span><span class="token punctuation">(</span><span class="token string">"addMediaResource"</span><span class="token punctuation">,</span> self<span class="token punctuation">.</span>uploadIds<span class="token punctuation">)</span><span class="token punctuation">;</span>
      self<span class="token punctuation">.</span>updateState <span class="token operator">=</span> <span class="token boolean">false</span>
      self<span class="token punctuation">.</span><span class="token function">handleClose</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token keyword">return</span> uploader
<span class="token punctuation">}</span><span class="token punctuation">,</span>

好的,批量上传功能完成,
我原来还以为上传多个需要循环什么的,死活搞不好各种百度搜,后来也在一个大佬博客下发现只要在this.uploader.addFile()那里把文件循环加入就好了,其他的什么都不要管,new AliyunUpload.Vod(){}方法会一次帮你上传的,进度条也只需一条就好了

感觉自己又提升了呢,加油加油加油

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/737605.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

集合List和Map

ArrayList底层的实现原理 初始化后ArrayList添加元素的步骤 首先计算数组的容量&#xff0c;如果当前数组已使用长度1后的大于当前的数组长度&#xff0c;则调用grow方法扩容(原来的1.5倍)&#xff0c;确保新增的数据有地方存储之后&#xff0c;则添加元素到size的位置上。返回…

docker环境下安装mysql 5.6

一、查看mgsql镜像版本 docker search mysql 二、拉取mysql镜像到本地标签为5.6版本 docker pull mysql:5.6 三、使用mysql5.6镜像创建容器(也叫运行镜像) 1.执行命令&#xff1a; docker run -p 3306:3306 --name mysql -v /haolb/mysql/conf:/etc/mysql/conf.d -v /haolb/my…

P2P、BT、ED2k、FTP、磁力链接下载到底是什么鬼?

1、HTTP/HTTPS 下载 有小伙伴会问&#xff0c;这个协议不是用来浏览网页的时候用的吗&#xff1f; 其实不然&#xff0c;用来下载文件一样可以&#xff0c;本质上都是从服务器拉取资源到本地&#xff0c;不同的是网页内容被渲染到浏览器上&#xff0c;而文件直接放在你的下载…

财富航向:企业为何急需财务管理软件?

随着市场的竞争日益激烈&#xff0c;企业对于财务数据的管理越来越重视。财务管理软件存在的好处越来越明显&#xff0c;它们可以帮助企业更好地管理财务信息并提高工作效率。 企业为什么需要财务管理软件&#xff1f; 1、方便管理财务数据 财务管理软件能够方便地管理与公司财…

教程学习:AutoQSAR

教程和练习文件从软件官网下载 内容&#xff1a; 1、拷贝教程提供的练习文件素材&#xff1a; 在软件的help中选择需要的教程&#xff0c;点击Copy to&#xff0c;可以将教程需要的文件拷贝到指定的文件夹里。点击Browse可以进行预览。 2、建立一个数值型的QSAR模型评估结合…

msvcr120.dll找不到是什么原因,怎样修复

msvcr120.dll的定义 msvcr120.dll是微软Visual C Redistributable软件包中的一个动态链接库文件。它是Microsoft Visual 所需的一个重要组件。这个文件主要用于支持和管理C语言编写的应用程序的运行。它包含了许多C的运行库函数和类&#xff0c;以便应用程序能够正常运行和调用…

2023-07-10:Kafka如何做到消息不丢失?

2023-07-10&#xff1a;Kafka如何做到消息不丢失&#xff1f; 答案2023-07-10&#xff1a; Kafka采用多种机制来确保消息的不丢失&#xff0c;其中包括副本机制、ISR&#xff08;In-Sync Replicas&#xff09;机制以及ACK机制等。 1.副本机制 Kafka通过副本机制来确保消息不…

【ElasticSearch】ES自动补全查询与Java接口实现

文章目录 1、安装拼音分词器2、自定义分词器3、completion suggester查询4、hotel索引库更新5、代码修改6、RestAPI实现自动补全7、需求&#xff1a;搜索框实现自动补全 自动补全就是当用户在搜索框输入字符时&#xff0c;我们应该提示出与该字符有关的搜索项。 1、安装拼音分词…

“小程序化”,一种创新的超级App开发模式

超级App是一种集成了多个功能和服务的移动应用程序&#xff0c;它在一个平台上提供了广泛的服务和体验。超级App通常具有大量的用户群体和高度活跃的用户社区&#xff0c;通过提供便利、多样化的功能&#xff0c;吸引用户在一个应用中完成多个任务和满足多个需求。 与传统的单…

postgresql 数据库 重建索引 所需时间测试

postgresql 数据库 重建索引 所需时间测试 文章目录 postgresql 数据库 重建索引 所需时间测试前言测试前准备重建索引前数据库状态测试计划重建索引命令测试开始1.先对表2进行测试2. 表3测试3. 表1测试 &#x1f308;后记 前言 众所周知&#xff0c;postgresql数据库使用久了…

【业务功能篇42】ThreadPoolTaskExecutor多线程处理耗时较高的数据接口

业务场景&#xff1a;当前业务模块中&#xff0c;有个查询产品直通率接口&#xff0c;随着数据量的递增&#xff0c;百万级数据&#xff0c;并且需要并表的情况下&#xff0c;那么返回数据就会开始变慢&#xff0c;而在数据层方面&#xff0c;已经比较难去做进一步的sql优化&am…

一致性哈希算法小结

在实际生产应用中&#xff0c;经常会设置多台服务器共同组成一个集成对外提供服务&#xff0c;为了确保合理的分配来自客户端的请求&#xff0c;我们会采取负载均衡的策略。例如采用「轮询」的方式让每个节点都能公平的接收到请求&#xff1b;采用「加权轮询」的方式让硬件配置…

MySQL-MySQL分组查询每组最新的一条数据

方法一&#xff1a; 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘se_jck的博客-CSDN博客 这个错误是由于 MySQL 的新版本中默认开启了ONLY_FULL_GROUP_BY模式&#xff0c;即在 GROUP BY 语句中的 SELECT 列表中&am…

[MMDetection]测试模型

以下是基于MMdetection3.10版本 1、简单测试模型 测试模型一般使用tools中的test.py&#xff0c;一般使用方式 python tools/test.py config文件路径 权重文件路径 可以通过--show 来以gui展示检测结果 python tools/test.py config文件路径 权重文件路径 --show 可以通过--s…

【Linux】部署Prometheus + Grafana简介、监控及设置告警详细操作(多种方式安装,亲测无问题)

&#x1f341;博主简介 &#x1f3c5;云计算领域优质创作者   &#x1f3c5;华为云开发者社区专家博主   &#x1f3c5;阿里云开发者社区专家博主 &#x1f48a;交流社区&#xff1a;运维交流社区 欢迎大家的加入&#xff01; 文章目录 一、环境准备二、部署 Prometheus&am…

优思学院|精益管理入门书籍有哪些推荐?

精益管理是一门易学难精的学问&#xff0c;如果对其基本原则了解不正确&#xff0c;可能会误入歧途&#xff0c;不但不能发挥精益工具的威力&#xff0c;甚至会令企业走向错误的方向&#xff0c;反带来更多的浪费和捐失。以下将介绍几本经典的书籍&#xff0c;可以让你有效地、…

python简单使用【mac-ide:pycharm】

小白实用快捷键记录 一、Mac下安装并配置python3开发环境二、python学习三、pycharm常用快捷键记录 一、Mac下安装并配置python3开发环境 点我查看python及pycharm下载安装、环境配置 二、python学习 不是很推荐&#xff0c;想系统学习的同学可以做个参考&#xff1a; Pytho…

排序之玩转qsort函数——【C语言】

说起排序&#xff0c;我们会想起许多算法&#xff0c;在之前的博客中我也写到过&#xff0c;比如&#xff1a;冒泡排序法、快速排序法、选择排序法等等。其实在C语言中一直有一个可以将数组中的内容进行排序的函数且功能完善内容齐全的库函数——qsort函数。今天就让我们来探索…

OpenPCDet系列 | 8.2 nuScenes数据集的eval流程

0. eval转换的目标 模型的训练和测试过程输出结果是不一样的&#xff0c;对于训练过程是为了构建损失函数来进行训练&#xff0c;而对于测试过程是为了对object进行预测生成预测内容。下面以VoxelNeX检测器的类代码可见&#xff0c;training和testing将会输出两个内容。 clas…

C++数据结构笔记(7)——队列的顺序结构实现

1.队列&#xff0c;和现实生活中的规则类似&#xff0c;先进先出 2.队尾只允许元素进入&#xff0c;队头只允许元素退出 3.用数组来实现队列的顺序存储&#xff0c;无论哪一段都可以作为队头或者队尾 SeqQueue.h头文件 #ifndef SEQQUEUE_H #define SEQQUEUE_H #include<…