Skip to content

Commit

Permalink
Removed small file from project since it couldn't be found by the E2E…
Browse files Browse the repository at this point in the history
… test harness, creating as part of operation now

Signed-off-by: Whit Waldo <[email protected]>
  • Loading branch information
WhitWaldo committed Jan 15, 2025
1 parent 1e3d8b5 commit 9806df9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 37 deletions.
6 changes: 0 additions & 6 deletions examples/Client/Cryptography/Cryptography.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,4 @@
<ProjectReference Include="..\..\..\src\Dapr.Client\Dapr.Client.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="smallfile.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public override async Task RunAsync(CancellationToken cancellationToken)
{
using var client = new DaprClientBuilder().Build();

// The name of the file we're using as an example
const string fileName = "./smallfile.txt";
//Create the small data file
var tempSmallFile = await CreateSmallFileAsync();

Console.WriteLine("Original file contents:");
foreach (var line in await File.ReadAllLinesAsync(fileName, cancellationToken))
foreach (var line in await File.ReadAllLinesAsync(tempSmallFile, cancellationToken))
{
Console.WriteLine(line);
}

//Encrypt from a file stream and buffer the resulting bytes to an in-memory buffer
await using var encryptFs = new FileStream(fileName, FileMode.Open);
await using var encryptFs = new FileStream(tempSmallFile, FileMode.Open);

var bufferedEncryptedBytes = new ArrayBufferWriter<byte>();
await foreach (var bytes in (await client.EncryptAsync(componentName, encryptFs, keyName,
Expand Down Expand Up @@ -66,8 +66,45 @@ public override async Task RunAsync(CancellationToken cancellationToken)
Console.WriteLine("Decrypted value: ");
Console.WriteLine(decryptedValue);

//And some cleanup to delete our temp file
//And some cleanup to delete our temp files
File.Delete(tempSmallFile);
File.Delete(tempDecryptedFile);
}

private static async Task<string> CreateSmallFileAsync()
{
const string fileData = """
# The Road Not Taken
## By Robert Lee Frost
Two roads diverged in a yellow wood,
And sorry I could not travel both
And be one traveler, long I stood
And looked down one as far as I could
To where it bent in the undergrowth;
Then took the other, as just as fair
And having perhaps the better claim,
Because it was grassy and wanted wear;
Though as for that, the passing there
Had worn them really about the same,
And both that morning equally lay
In leaves no step had trodden black
Oh, I kept the first for another day!
Yet knowing how way leads on to way,
I doubted if I should ever come back.
I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference.
""";

var tempFileName = Path.GetTempFileName();
await File.WriteAllTextAsync(tempFileName, fileData);
return tempFileName;
}
}
}
2 changes: 2 additions & 0 deletions examples/Client/Cryptography/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ static async Task<int> Main(string[] args)
Console.WriteLine();
return 1;
}


}
}
26 changes: 0 additions & 26 deletions examples/Client/Cryptography/smallfile.txt

This file was deleted.

0 comments on commit 9806df9

Please sign in to comment.