Class StoredPdfs

java.lang.Object
io.leandev.appfuse.pdf.StoredPdfs

public final class StoredPdfs extends Object

把 PdfArtifact 保存到 FileStorage

StoredPdf stored = StoredPdfs.save(fileStorage, partition, renderer.render(document, options, "form.pdf"));

partition 必須是經應用驗證的可信分區識別,不可直接接受外部輸入或路徑片段(如 ..)。 partition 由應用決定:tenant 模組傳目前 tenant ID,tenantless 模組傳應用常數或依資料範圍設計的值。 保存期限由應用以 StoredPdf.storedAt() 計算並自行刪除;框架不排程刪除。

Since:
4.0.0
  • Method Details

    • save

      public static StoredPdf save(FileStorage storage, String partition, PdfArtifact artifact)
      以系統時鐘記錄保存時間;見 save(FileStorage, String, PdfArtifact, Clock)
    • save

      public static StoredPdf save(FileStorage storage, String partition, PdfArtifact artifact, Clock clock)

      保存並關閉 artifact

      接手 artifact 的 ownership:成功或失敗都會關閉。寫入成功即回傳結果;之後的清理失敗(讀取串流的關閉、 暫存檔刪除)只記錄 WARN,不影響回傳。寫入失敗時儲存的例外為主例外,不回傳結果;串流關閉的錯誤以 suppressed 附上。

      Parameters:
      storage - 檔案儲存
      partition - 儲存分區鍵(不可為 null)
      artifact - 產物;此方法負責關閉
      clock - 保存時間的時鐘(與 FixedPdfRenderer.Options.clock 無關)
      Returns:
      保存結果