From 1989ca7ef76143ddb0acfa7e9ebe9da2ebc056f0 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 21 Jul 2026 09:26:04 +0200 Subject: [PATCH] feat: Add ExtractPdfAttachments Application layer (Command/Handler/Validator merged) --- .../ExtractPdfAttachmentsCommand.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 DocumentOperator.Application/ExtractPdfAttachments/ExtractPdfAttachmentsCommand.cs diff --git a/DocumentOperator.Application/ExtractPdfAttachments/ExtractPdfAttachmentsCommand.cs b/DocumentOperator.Application/ExtractPdfAttachments/ExtractPdfAttachmentsCommand.cs new file mode 100644 index 0000000..7572e37 --- /dev/null +++ b/DocumentOperator.Application/ExtractPdfAttachments/ExtractPdfAttachmentsCommand.cs @@ -0,0 +1,43 @@ +using DocumentOperator.Application.Common.Interfaces; +using FluentValidation; +using MediatR; + +namespace DocumentOperator.Application.ExtractPdfAttachments; + +/// +/// Command to extract all embedded files from a PDF document and return as ZIP archive. +/// +public record ExtractPdfAttachmentsCommand : IRequest +{ + /// + /// PDF document stream. Must be positioned at the beginning (Position = 0). + /// + public required Stream PdfStream { get; init; } +} + +/// +/// Handler for ExtractPdfAttachmentsCommand. +/// Extracts all embedded files from PDF and returns as ZIP archive. +/// +public class ExtractPdfAttachmentsCommandHandler(IPdfProcessor pdfProcessor) + : IRequestHandler +{ + public async Task Handle(ExtractPdfAttachmentsCommand request, CancellationToken cancellationToken) + { + // Delegate to infrastructure layer + return await pdfProcessor.ExtractAttachmentsAsync(request.PdfStream); + } +} + +/// +/// Validator for ExtractPdfAttachmentsCommand. +/// +public class ExtractPdfAttachmentsCommandValidator : AbstractValidator +{ + public ExtractPdfAttachmentsCommandValidator() + { + RuleFor(x => x.PdfStream) + .NotNull() + .WithMessage("PDF stream is required"); + } +}