Nuuvify.CommonPack.MftMailbox.Sftp 2.6.0-test.26070804

This is a prerelease version of Nuuvify.CommonPack.MftMailbox.Sftp.
dotnet add package Nuuvify.CommonPack.MftMailbox.Sftp --version 2.6.0-test.26070804
                    
NuGet\Install-Package Nuuvify.CommonPack.MftMailbox.Sftp -Version 2.6.0-test.26070804
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nuuvify.CommonPack.MftMailbox.Sftp" Version="2.6.0-test.26070804" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nuuvify.CommonPack.MftMailbox.Sftp" Version="2.6.0-test.26070804" />
                    
Directory.Packages.props
<PackageReference Include="Nuuvify.CommonPack.MftMailbox.Sftp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nuuvify.CommonPack.MftMailbox.Sftp --version 2.6.0-test.26070804
                    
#r "nuget: Nuuvify.CommonPack.MftMailbox.Sftp, 2.6.0-test.26070804"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nuuvify.CommonPack.MftMailbox.Sftp@2.6.0-test.26070804
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nuuvify.CommonPack.MftMailbox.Sftp&version=2.6.0-test.26070804&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Nuuvify.CommonPack.MftMailbox.Sftp&version=2.6.0-test.26070804&prerelease
                    
Install as a Cake Tool

Nuuvify.CommonPack.MftMailbox.Sftp

PR Validation Publish and Release NuGet Downloads

Adapter SFTP para MFT Mailbox com suporte a:

  • envio e recebimento por streaming
  • commit atômico em upload (tmp + rename)
  • status por item
  • confirmação ACK/NACK por metadado ou arquivo marcador

Índice

Quando usar

  • Integrações de transferência de arquivo com servidores SFTP.
  • Processamento de lote com rastreabilidade por item.
  • Necessidade de comportamento resiliente para rede instável.

Dependências

  • Nuuvify.CommonPack.MftMailbox
  • Nuuvify.CommonPack.MftMailbox.Abstraction
  • SSH.NET

Instalação

<PackageReference Include="Nuuvify.CommonPack.MftMailbox.Sftp" Version="x.x.x" />

Configuração

SftpMftMailboxOptions

  • Host
  • Port
  • Username
  • Password ou PrivateKeyPath/PrivateKeyPassphrase
  • HostKeyFingerprint
  • OutboundDirectory
  • InboundDirectory
  • ArchiveSuccessDirectory
  • ArchiveErrorDirectory
  • AckMarkerDirectory
  • AckNackMode (Metadata ou MarkerFile)

Registro no DI

using Nuuvify.CommonPack.MftMailbox;
using Nuuvify.CommonPack.MftMailbox.Sftp;
using Nuuvify.CommonPack.MftMailbox.Sftp.Configuration;

builder.Services.AddMftMailboxCore();

builder.Services.AddMftMailboxSftp(options =>
{
	options.Host = "sftp.example.local";
	options.Port = 22;
	options.Username = "integration-user";
	options.PrivateKeyPath = "/secrets/id_rsa";
	options.HostKeyFingerprint = "ab12cd34ef56...";
	options.OutboundDirectory = "/outbound";
	options.InboundDirectory = "/inbound";
	options.ArchiveSuccessDirectory = "/archive/success";
	options.ArchiveErrorDirectory = "/archive/error";
	options.AckMarkerDirectory = "/ack";
	options.AckNackMode = SftpAckNackMode.Metadata;
});

Exemplo de envio

using Nuuvify.CommonPack.MftMailbox.Abstraction.Interfaces;
using Nuuvify.CommonPack.MftMailbox.Abstraction.Models;

public sealed class SftpOutboundService
{
	private readonly IMftClientFactory _factory;

	public SftpOutboundService(IMftClientFactory factory)
	{
		_factory = factory;
	}

	public async Task<TransferItemResult> SendAsync(byte[] payload, CancellationToken ct)
	{
		var client = _factory.CreateTransferClient(MftProtocol.Sftp);

		var envelope = new TransferEnvelope
		{
			IntegrationKey = "supplier-a",
			CorrelationId = Guid.NewGuid().ToString("N"),
			Protocol = MftProtocol.Sftp,
			Items = new List<TransferItem>
			{
				new()
				{
					ItemId = Guid.NewGuid().ToString("N"),
					FileName = "invoice.csv",
					ContentFactory = _ => Task.FromResult<Stream>(new MemoryStream(payload))
				}
			}
		};

		return await client.SendSingleAsync(envelope, ct);
	}
}

Exemplo de recebimento

using Nuuvify.CommonPack.MftMailbox.Abstraction.Interfaces;
using Nuuvify.CommonPack.MftMailbox.Abstraction.Models;

public sealed class SftpInboundService
{
	private readonly IMftClientFactory _factory;

	public SftpInboundService(IMftClientFactory factory)
	{
		_factory = factory;
	}

	public async Task<IReadOnlyCollection<InboundTransferItem>> ReceiveAsync(CancellationToken ct)
	{
		var client = _factory.CreateInboundClient(MftProtocol.Sftp);

		var envelope = new TransferEnvelope
		{
			IntegrationKey = "supplier-a",
			CorrelationId = Guid.NewGuid().ToString("N"),
			Protocol = MftProtocol.Sftp
		};

		return await client.ReceiveBatchAsync(envelope, ct);
	}
}

ACK/NACK

O adapter suporta dois modos:

  • Metadata: move arquivo para pasta de sucesso/erro.
  • MarkerFile: cria arquivo marcador na pasta de ACK.

Exemplo:

var client = _factory.CreateAckNackClient(MftProtocol.Sftp);

await client.AckOrNackAsync(new AckNackCommand
{
	IntegrationKey = "supplier-a",
	CorrelationId = Guid.NewGuid().ToString("N"),
	ItemId = "item-01",
	FileName = "invoice.csv",
	Protocol = MftProtocol.Sftp,
	Decision = AckNackType.Ack
}, ct);

Segurança

  • Prefira autenticação por chave privada.
  • Defina HostKeyFingerprint para pinning de host key.
  • Evite logar payload e segredos.
  • Mantenha diretórios segregados por integração.

Troubleshooting

  • Connection timeout: revise host, porta, firewall e timeout por arquivo.
  • Falha em autenticação: valide credenciais/chave e permissões no servidor.
  • Erro de host key: confirme fingerprint e política de rotação.
  • Muitos arquivos no lote: ajuste MaxBatchSize no núcleo MFT.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.6.0-test.26070804 1 7/8/2026

# Changelog - Nuuvify.CommonPack.MftMailbox.Sftp

Todas as mudancas notaveis deste pacote serao documentadas neste arquivo.

O formato e baseado em [Keep a Changelog](https://keepachangelog.com/pt-br/1.0.0/),
e este projeto adere ao [Semantic Versioning](https://semver.org/lang/pt-BR/spec/v2.0.0.html).

## [Nao Lancado]

### Adicionado
- Adapter SFTP com upload/download streaming, commit atomico e ACK/NACK.

### Alterado

### Corrigido

### Removido

### Seguranca