Pārlūkot izejas kodu

fix: export with PDF to lowercase file

ryanemax 2 mēneši atpakaļ
vecāks
revīzija
6df1029f50
2 mainītis faili ar 6 papildinājumiem un 3 dzēšanām
  1. 2 1
      server/cloud/tbook/test/test-export.js
  2. 4 2
      server/lib/docs/index.js

+ 2 - 1
server/cloud/tbook/test/test-export.js

@@ -24,7 +24,8 @@ async function main(){
         // console.log(await exportProcessReportDocs(null,["9V575dapEM"]))
         // console.log(await exportProcessReportDocs(null,["c2WUE5PgCo"]))
         // console.log(await exportProcessReportDocs(null,["R9r0XtMsK3"])) // CIP顺序问题,后两个pdf到了最前面
-        console.log(await exportProcessReportDocs(null,["MU5YpUizfW"]))
+        // console.log(await exportProcessReportDocs(null,["MU5YpUizfW"]))
+        console.log(await exportProcessReportDocs(null,["UUGgHPHsIC"]))
         // console.log(await exportProcessReportDocs(null,["KvvN9lWhri"]))
         // console.log(await exportProcessReportDocs(null,["F8eiOAfuC3"]))
         

+ 4 - 2
server/lib/docs/index.js

@@ -127,7 +127,8 @@ async function downloadUrl(url) {
     console.log(url)
     if(url?.startsWith("/")) {return url};
     let md5 = crypto.createHash('md5');
-    let filename = md5.update(url).digest('hex') + path.extname(url)
+    let extname = path.extname(url)?.toLocaleLowerCase();
+    let filename = md5.update(url).digest('hex') + extname;
     let filepath = path.join(tempDir,filename)
     // console.log(filename,filepath)
     try{
@@ -283,7 +284,8 @@ export async function mergePdfListReduce(pdfList,convertOpts){
             if(files?.length==1){ // 单文件直接加载 自动获取后缀
                 let onefile = files[0]
                 if(!onefile?.ext){
-                    onefile = {data:fs.readFileSync(onefile),ext:path.extname(files[0]).slice(1)}
+                    let extname = path.extname(files[0]).slice(1)?.toLocaleLowerCase();
+                    onefile = {data:fs.readFileSync(onefile),ext:extname}
                 }
                 resolve(onefile);
             }else{ // 多文件合并