Skip to content

Commit

Permalink
Updated to the newest KekUploadLibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
CraftingDragon007 committed May 25, 2022
1 parent a7c7882 commit 8a516ca
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
6 changes: 3 additions & 3 deletions KekUploadCLIClient/DownloadCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class DownloadCommand : ConsoleCommand
{
private const int Success = 0;
private const int Failure = 2;
public string? FileLocation { get; set; }
public string? DownloadUrl { get; set; }

private string? FileLocation { get; set; }
private string? DownloadUrl { get; set; }

public DownloadCommand()
{
Expand Down
3 changes: 2 additions & 1 deletion KekUploadCLIClient/KekUploadCLIClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyVersion>1.0.0.4</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CraftingDragon007.KekUploadLibrary" Version="1.0.0.3" />
<PackageReference Include="CraftingDragon007.KekUploadLibrary" Version="1.0.0.4" />
<PackageReference Include="ManyConsole" Version="2.0.1" />
</ItemGroup>

Expand Down
16 changes: 5 additions & 11 deletions KekUploadCLIClient/Program.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Text;
using ManyConsole;

namespace KekUploadCLIClient
{
class Program
public class Program
{
public const string Version = "1.0.0.3";
public const string Version = "1.0.0.4";

private static TextWriter? _console;

public static int Main(string[] args)
{
StringBuilder builder = new StringBuilder();
var builder = new StringBuilder();
foreach (var s in args)
{
builder.Append(s);
Expand All @@ -42,7 +36,7 @@ public static IEnumerable<ConsoleCommand> GetCommands()
return ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
}

public static bool Silent { get; set; }
public static bool Silent { get; private set; }
public static void WriteLine(string text)
{
_console?.WriteLine(text);
Expand Down
20 changes: 14 additions & 6 deletions KekUploadCLIClient/UploadCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ public class UploadCommand : ConsoleCommand
{
private const int Success = 0;
private const int Failure = 2;

public string? FileLocation { get; set; }
public string? ApiBaseUrl { get; set; }
public int ChunkSize { get; set; }

private string? FileLocation { get; set; }
private string? ApiBaseUrl { get; set; }
private int ChunkSize { get; set; }
private bool Name { get; set; }

public UploadCommand()
{
Expand All @@ -21,6 +22,13 @@ public UploadCommand()
HasRequiredOption("u|url=", "The base Api Url from the upload Server", p => ApiBaseUrl = p);
HasOption("c|chunkSize=", "The Size of the Chunks for uploading (in KiB)", t => ChunkSize = t == null ? 1024*1024*2 : Convert.ToInt32(t));
HasOption("s|silent=", "If the command should be executed silently", t =>{});
var actionNameWasExecuted = false;
HasOption("n|name=", "If the file should be uploaded with a name", t =>
{
Name = t == null || Convert.ToBoolean(t);
actionNameWasExecuted = true;
});
if(!actionNameWasExecuted) Name = true;
}

public override int Run(string[] remainingArguments)
Expand All @@ -35,7 +43,7 @@ public override int Run(string[] remainingArguments)
var fileInfo = new FileInfo(file);
ChunkSize = ChunkSize <= 0 ? 1024 * 2 : ChunkSize;
ChunkSize *= 1024;
var client = new UploadClient(ApiBaseUrl, ChunkSize);
var client = new UploadClient(ApiBaseUrl, ChunkSize, Name);
ProgressBar? progressBar = null;
client.UploadStreamCreateEvent += (sender, args) =>
{
Expand All @@ -59,7 +67,7 @@ public override int Run(string[] remainingArguments)

try
{
var url = client.UploadFile(file);
var url = client.Upload(new UploadItem(file));
Program.WriteLine("");
Program.WriteLine("Finished the upload! Download Url: " + url);
if(Program.Silent) Console.WriteLine(url);
Expand Down

0 comments on commit 8a516ca

Please sign in to comment.