// AmoosedWeb.Reader example for .NET 10 on Windows x64. // Usage: dotnet run -- https://site.example/ ./downloads [index.amwkey] [member.amwmember] using AmoosedWeb.Reader; if (args.Length < 2) { Console.Error.WriteLine("Usage: dotnet run -- https://site.example/ ./downloads [index.amwkey] [member.amwmember]"); return 2; } try { var reader = new AmoosedReader( new Uri(args[0]), indexKeyFile: args.Length > 2 ? args[2] : null, memberKeyFile: args.Length > 3 ? args[3] : null); var resources = await reader.ListAsync(); foreach (var resource in resources) Console.WriteLine($"{resource.Access,-7} {resource.Bytes,10} {resource.Path}"); var candidate = resources.FirstOrDefault(resource => resource.Delivery == "download" && (resource.Access == "public" || args.Length > 3)); if (candidate is null) { Console.WriteLine("No accessible download resource was listed."); return 0; } Directory.CreateDirectory(args[1]); var output = Path.Combine(args[1], Path.GetFileName(candidate.Path)); var result = await reader.DownloadAsync(candidate.Path, output); Console.WriteLine($"Verified {result.Bytes} bytes, SHA-256 {result.Sha256}, saved to {result.Path}"); return 0; } catch (Exception exception) { Console.Error.WriteLine(exception.Message); return 1; }