From 73a7afe2570121ed3a76a5b01fafd7e92245d4cd Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 20 Jul 2026 11:55:08 +0200 Subject: [PATCH] refactor: Change IPdfProcessor interface from byte[] to Stream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ValidateAsync(byte[]) → ValidateAsync(Stream) - ValidatePdfAAsync(byte[]) → ValidatePdfAAsync(Stream) - CheckAttachmentsAsync(byte[]) → CheckAttachmentsAsync(Stream) - Reason: Stream-based processing reduces memory footprint and enables pipeline parallelization --- .../Common/Interfaces/IPdfProcessor.cs | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/DocumentOperator.Application/Common/Interfaces/IPdfProcessor.cs b/DocumentOperator.Application/Common/Interfaces/IPdfProcessor.cs index bbbb224..9c7795c 100644 --- a/DocumentOperator.Application/Common/Interfaces/IPdfProcessor.cs +++ b/DocumentOperator.Application/Common/Interfaces/IPdfProcessor.cs @@ -1,4 +1,4 @@ -using DocumentOperator.Domain.Models.ValueObjects; +using DocumentOperator.Application.Common.DTOs; namespace DocumentOperator.Application.Common.Interfaces; @@ -7,20 +7,30 @@ public interface IPdfProcessor /// /// Validates a PDF and extracts metadata. /// - /// PDF content as byte array + /// PDF content as stream (caller is responsible for disposal) /// PDF metadata (page count, size, version, attachments) - /// - /// Thrown when PDF is corrupted or cannot be processed + /// + /// Thrown when stream is empty or invalid /// - Task ValidateAsync(byte[] pdfBytes); + Task ValidateAsync(Stream pdfStream); /// /// Validates a PDF/A document and checks conformance level. /// - /// PDF content as byte array + /// PDF content as stream (caller is responsible for disposal) /// PDF/A metadata including conformance level and validation errors/warnings - /// - /// Thrown when PDF is corrupted or cannot be processed + /// + /// Thrown when stream is empty or invalid /// - Task ValidatePdfAAsync(byte[] pdfBytes); + Task ValidatePdfAAsync(Stream pdfStream); + + /// + /// Checks for embedded files (attachments) in a PDF document and returns detailed metadata. + /// + /// PDF content as stream (caller is responsible for disposal) + /// Attachment information (count, file names, MIME types, sizes) + /// + /// Thrown when stream is empty or invalid + /// + Task CheckAttachmentsAsync(Stream pdfStream); } \ No newline at end of file