Sfoglia il codice sorgente

学情生成pdf效果制作

yemeishu 2 settimane fa
parent
commit
3afc35be30
1 ha cambiato i file con 18 aggiunte e 2 eliminazioni
  1. 18 2
      app/Services/ExamPdfExportService.php

+ 18 - 2
app/Services/ExamPdfExportService.php

@@ -74,7 +74,15 @@ class ExamPdfExportService
 
             $version = time();
             $path = "analysis_reports/{$paperId}_{$studentId}_{$version}.pdf";
-            Storage::disk('public')->put($path, $pdfBinary);
+            Storage::disk('public')->makeDirectory('analysis_reports');
+            $written = Storage::disk('public')->put($path, $pdfBinary);
+            if (!$written) {
+                Log::error('ExamPdfExportService: 保存学情 PDF 失败', [
+                    'disk' => 'public',
+                    'path' => $path,
+                ]);
+                return null;
+            }
 
             return URL::to(Storage::url($path));
         } catch (\Throwable $e) {
@@ -117,7 +125,15 @@ class ExamPdfExportService
             }
 
             $path = "exams/{$paperId}_{$suffix}.pdf";
-            Storage::disk('public')->put($path, $pdfBinary);
+            Storage::disk('public')->makeDirectory('exams');
+            $written = Storage::disk('public')->put($path, $pdfBinary);
+            if (!$written) {
+                Log::error('ExamPdfExportService: 保存 PDF 失败', [
+                    'disk' => 'public',
+                    'path' => $path,
+                ]);
+                return null;
+            }
 
             return URL::to(Storage::url($path));
         } catch (\Throwable $e) {