public async ValueTask <GetDocumentContentGrpcResponse> DownloadDocumentAsync(DocumentGrpcContract request) { var document = await ServiceLocator.TraderDocumentsPostgresRepository .GetDocumentsAsync(request.TraderId, request.Id); if (document == null) { return new GetDocumentContentGrpcResponse { DocumentContent = null } } ; var fileContent = await ServiceLocator.AzureBlobContainer.DownloadBlobAsync(document.FileName); var encodedFileContent = AesEncodeDecode.Decode(fileContent.ToArray(), ServiceLocator.EncodingKey); return(new GetDocumentContentGrpcResponse { DocumentContent = new TraderDocumentContentGrpcModel { Mime = document.Mime, Data = encodedFileContent, FileName = document.FileName } }); }
public static string DecodeString(this string str, byte[] key) { var data = str.HexStringToByteArray(); return(Encoding.UTF8.GetString(AesEncodeDecode.Decode(data, key))); }