CraftingDragon007.KekUploadLibrary
1.0.0.6
.NET 7.0
This package targets .NET 7.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CraftingDragon007.KekUploadLibrary --version 1.0.0.6
NuGet\Install-Package CraftingDragon007.KekUploadLibrary -Version 1.0.0.6
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="CraftingDragon007.KekUploadLibrary" Version="1.0.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CraftingDragon007.KekUploadLibrary --version 1.0.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CraftingDragon007.KekUploadLibrary, 1.0.0.6"
#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.
// Install CraftingDragon007.KekUploadLibrary as a Cake Addin #addin nuget:?package=CraftingDragon007.KekUploadLibrary&version=1.0.0.6 // Install CraftingDragon007.KekUploadLibrary as a Cake Tool #tool nuget:?package=CraftingDragon007.KekUploadLibrary&version=1.0.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
KekUploadLibrary
A simple C# Library for UploadServer
Installation
You can install this Library via NuGet:
PM> Install-Package CraftingDragon007.KekUploadLibrary
Usage
Using the upload client:
using System;
using System.IO;
using KekUploadLibrary;
class Program
{
static void Main(string[] args)
{
var client = new UploadClient("<Your UploadServer URL>", <If you want to also upload the filenames>);
// Diffrent Events are available (Optional)
client.UploadCompleteEvent += (sender, e) => Console.WriteLine("Upload Complete: " + e.FileUrl);
client.UploadChunkCompleteEvent += (sender, e) => Console.WriteLine("Upload progress: {0}/{1}", e.CurrentChunkCount, e.TotalChunkCount);
client.UploadErrorEvent += (sender, e) =>
{
if(e.ErrorResponse != null)
{
Console.WriteLine("Error: " + e.ErrorResponse);
Console.WriteLine("Exception: " + e.Exception);
}else
{
Console.WriteLine("Error: " + e.Exception);
}
};
client.UploadStreamCreateEvent += (sender, e) => Console.WriteLine("Upload Stream created: " + e.UploadStreamId);
// Upload a file
client.Upload(new UploadItem("<Your File Path>"));
// Upload a stream
using(var stream = new FileStream("<FilePath>", FileMode.Open))
{
client.Upload(new UploadItem(stream, "<Extension>", "<Filename>")); // the filename is optional and must not contain the extension
}
// Upload a byte array
client.Upload(new UploadItem(File.ReadAllBytes("<FilePath>"), "<Extension>", "<Filename>")); // the filename is optional and must not contain the extension
// The upload method returns the download url of the uploaded file
}
}
Using the chunked upload stream:
using System;
using System.IO;
using KekUploadLibrary;
class Program
{
static void Main(string[] args)
{
var stream = new ChunkedUploadStream("<Extension>", "<Your UploadServer URL>", "<Filename>"); // the filname can be null and must not contain the extension
// Diffrent Events are available (Optional)
stream.UploadChunkCompleteEvent += (sender, e) => Console.WriteLine("Upload progress: {0}/{1}", e.CurrentChunkCount, e.TotalChunkCount);
stream.UploadCompleteEvent += (sender, e) => Console.WriteLine("Upload Complete: " + e.FileUrl);
stream.UploadErrorEvent += (sender, e) =>
{
if(eventArgs.ErrorResponse != null)
{
Console.WriteLine("Error: " + e.ErrorResponse);
Console.WriteLine("Exception: " + e.Exception);
}else
{
Console.WriteLine("Error: " + e.Exception);
}
};
stream.UploadStreamCreateEvent += (sender, e) => Console.WriteLine("Upload Stream created: " + e.UploadStreamId);
// Now you can write everything you want to the stream
// The stream will be chunked and uploaded to the upload server
// It will only be uploaded, when you flush the stream
stream.Write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 0, 10);
stream.Flush();
// You can do this as often as you want
stream.Write(new byte[] { 2, 5, 3, 4, 5, 0, 7, 8, 4, 10 }, 0, 10);
stream.Flush();
// When you are done, you can finish the upload with a final request
stream.FinishUpload(); // This returns the download url of the uploaded bytes
// Then you can dispose the stream
stream.Dispose();
}
}
Downloading a file:
using System;
using KekUploadLibrary;
class Program
{
static void Main(string[] args)
{
var downloadClient = new DownloadClient();
downloadClient.ProgressChangedEvent += (totalFileSize, totalBytesDownloaded, progressPercentage) =>
{
Console.WriteLine($"Total file size: {totalFileSize}");
Console.WriteLine($"Total bytes downloaded: {totalBytesDownloaded}");
Console.WriteLine($"Progress percentage: {progressPercentage}");
};
downloadClient.Download("<Your download url>", new DownloadItem("<Your path>"));
}
}
License
This Library is licensed under the GNU General Public License v3.0
Contributing
If you want to contribute to this Library, please open an issue or pull request on GitHub.
Contributors
Contact
Email <br> Discord: CraftingDragon007#9504
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- CraftingDragon007.SharpHash (>= 1.2.0)
- Newtonsoft.Json (>= 13.0.2)
-
net7.0
- CraftingDragon007.SharpHash (>= 1.2.0)
- Newtonsoft.Json (>= 13.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.