瀏覽代碼

修改分析提交ai应用作业

11wqe1 3 月之前
父節點
當前提交
994a89dac7
共有 1 個文件被更改,包括 63 次插入3 次删除
  1. 63 3
      src/components/components/choseWorksDetailDialog.vue

+ 63 - 3
src/components/components/choseWorksDetailDialog.vue

@@ -1928,14 +1928,18 @@ export default {
   methods: {
 
     // 提交应用中心作业
-    upLoadApp(){
+    async upLoadApp(){
       let _iframe = this.$refs.appStore;
       document.getElementById('loadLi_JieE').children[0].style.display = "block"
 
 
         // window.exposed_outputs
-        let Cow = JSON.stringify(_iframe.contentWindow.exposed_outputs)
+        // let Cow = JSON.stringify(_iframe.contentWindow.exposed_outputs)
+        const pptJsonStr = JSON.stringify(_iframe.contentWindow.exposed_outputs);
+        const pptJsonFile = new File([pptJsonStr], "pptData.json", { type: "application/json" });
+        // 你可以根据需要将pptJsonFile上传或保存
 
+        let _url = await this.uploadFile(pptJsonFile);
         // uid: this.userId,
         //       cid: this.id,
         //       stage: this.courseType,
@@ -1951,7 +1955,7 @@ export default {
             stage: this.courseType,
             task: this.taskCount,
             tool: this.toolIndex,
-            content: Cow,
+            content: _url,
             type: 20,
             atool: 72
             }
@@ -1986,6 +1990,62 @@ export default {
                this.addOp3('1', "", { courseid: this.id,tool: 'AI应用',data: Cow,type: "course_tool_sub" }, err)
 
             });
+    },
+        //上传文件
+    uploadFile(file) {
+        return new Promise((resolve)=>{
+            var credentials = {
+            accessKeyId: "AKIATLPEDU37QV5CHLMH",
+            secretAccessKey: "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"
+        }; //秘钥形式的登录上传
+        window.AWS.config.update(credentials);
+        window.AWS.config.region = "cn-northwest-1"; //设置区域
+
+        var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
+        var _this = this;
+
+        if (file) {
+            var params = {
+            Key:
+                file.name.split(".")[0] +
+                new Date().getTime() +
+                "." +
+                file.name.split(".")[file.name.split(".").length - 1],
+            ContentType: file.type,
+            Body: file,
+            "Access-Control-Allow-Credentials": "*",
+            ACL: "public-read"
+            }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
+            var options = {
+            partSize: 2048 * 1024 * 1024,
+            queueSize: 2,
+            leavePartsOnError: true
+            };
+            bucket
+            .upload(params, options)
+            .on("httpUploadProgress", function(evt) {
+                //这里可以写进度条
+                // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
+            })
+            .send(function(err, data) {
+                if (err) {
+                // var a = _this.$refs.upload1.uploadFiles;
+                // a.splice(a.length - 1, a.length);
+                _this.$message.error("上传失败ppt数据失败");
+                } else {
+                //上传成功处理
+                // _this.unitJson[_this.unitIndex].chapterInfo[0].fileList1.push({
+                //   name: file.name,
+                //   url: data.Location,
+                //   uid: file.uid
+                // });
+                // _this.imgChange();
+                // console.log(data.Location);
+                resolve(data.Location)
+                }
+            });
+        }
+        })
     },
     // 设置分组
     updateGroupJson(){