lsc 1 day ago
parent
commit
5fe40b4019
1 changed files with 38 additions and 39 deletions
  1. 38 39
      src/hooks/useImport.ts

+ 38 - 39
src/hooks/useImport.ts

@@ -539,49 +539,49 @@ export default () => {
       // 8. 返回 File 对象
       return new File([outputBlob], filename, { type: 'image/png' })
     }
-
-    /**
+  }
+  /**
      * 上传 File 到 S3,返回公开访问的 URL
      */
-    const uploadFileToS3 = (file: File): Promise<string> => {
-      return new Promise((resolve, reject) => {
-        if (typeof window === 'undefined' || !window.AWS) {
-          reject(new Error('AWS SDK not available'))
-          return
-        }
+  const uploadFileToS3 = (file: File): Promise<string> => {
+    return new Promise((resolve, reject) => {
+      if (typeof window === 'undefined' || !window.AWS) {
+        reject(new Error('AWS SDK not available'))
+        return
+      }
 
-        const credentials = {
-          accessKeyId: 'AKIATLPEDU37QV5CHLMH',
-          secretAccessKey: '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',
-        }
-        window.AWS.config.update(credentials)
-        window.AWS.config.region = 'cn-northwest-1'
-
-        const bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' } })
-        const ext = file.name.split('.').pop() || 'bin'
-        const key = `${file.name.split('.')[0]}_${Date.now()}.${ext}`
-
-        const params = {
-          Key: 'pptto/' + key,
-          ContentType: file.type,
-          Body: file,
-          ACL: 'public-read',
-        }
-        const options = {
-          partSize: 2048 * 1024 * 1024, // 2GB 分片,可酌情调小
-          queueSize: 2,
-          leavePartsOnError: true,
-        }
+      const credentials = {
+        accessKeyId: 'AKIATLPEDU37QV5CHLMH',
+        secretAccessKey: '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',
+      }
+      window.AWS.config.update(credentials)
+      window.AWS.config.region = 'cn-northwest-1'
 
-        bucket
-          .upload(params, options)
-          .promise()
-          .then(data => resolve(data.Location))
-          .catch(err => reject(err))
-      })
-    }
+      const bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' } })
+      const ext = file.name.split('.').pop() || 'bin'
+      const key = `${file.name.split('.')[0]}_${Date.now()}.${ext}`
 
-    /*
+      const params = {
+        Key: 'pptto/' + key,
+        ContentType: file.type,
+        Body: file,
+        ACL: 'public-read',
+      }
+      const options = {
+        partSize: 2048 * 1024 * 1024, // 2GB 分片,可酌情调小
+        queueSize: 2,
+        leavePartsOnError: true,
+      }
+
+      bucket
+        .upload(params, options)
+        .promise()
+        .then(data => resolve(data.Location))
+        .catch(err => reject(err))
+    })
+  }
+
+  /*
     // 导入PPTX文件
     const importPPTXFile = (files: FileList, options?: { cover?: boolean; fixedViewport?: boolean; signal?: AbortSignal }) => {
       console.log('导入', files)
@@ -1124,7 +1124,6 @@ export default () => {
       })
     }
   */
-  }
 
   const importPPTXFile = (files: FileList, options?: { cover?: boolean; fixedViewport?: boolean; signal?: AbortSignal, onclose?: () => void }) => {
     console.log('导入', files)