Sfoglia il codice sorgente

投稿视频时,每次只能上传一个文件

reghao 4 anni fa
parent
commit
7dda87cf78

+ 5 - 1
src/components/upload/filepond-upload.vue

@@ -2,7 +2,7 @@
   <div>
     <file-pond
       ref="pond"
-      name="file[]"
+      name="file"
       label-idle="选择视频或者拖动视频到此处"
       label-file-processing="视频正在上传,请稍后"
       label-file-processing-aborted="视频上传被取消"
@@ -55,6 +55,10 @@ export default {
           headers: {
             'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
           },
+          ondata: (formData) => {
+            formData.append('userId', 12345678909)
+            return formData
+          },
           onload(res) {
             var resp = JSON.parse(res)
             // 返回上传数据

+ 5 - 5
src/components/upload/upload-video.vue

@@ -207,11 +207,11 @@ export default {
     // filepond 组件上传文件完成时调用
     videoUploadSuccess(value) {
       if (value.code === 0) {
-        this.videoInfo.infoId = value.data[0].infoId
-        this.setTitle(value.data[0].filename)
-        this.videoInfo.duration = value.data[0].duration
-        this.videoInfo.coverUrl = value.data[0].coverUrl
-        this.videoInfo.fileId = value.data[0].fileId
+        this.videoInfo.infoId = value.data.infoId
+        this.setTitle(value.data.filename)
+        this.videoInfo.duration = value.data.duration
+        this.videoInfo.coverUrl = value.data.coverUrl
+        this.videoInfo.fileId = value.data.fileId
 
         this.message = '视频上传成功'
         this.showMessage = true