CraftingDragon007.KekUploadLibrary
1.0.0.4
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.4
NuGet\Install-Package CraftingDragon007.KekUploadLibrary -Version 1.0.0.4
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.4" />
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.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CraftingDragon007.KekUploadLibrary, 1.0.0.4"
#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.4 // Install CraftingDragon007.KekUploadLibrary as a Cake Tool #tool nuget:?package=CraftingDragon007.KekUploadLibrary&version=1.0.0.4
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 + 1, e.TotalChunkCount);
client.UploadErrorEvent += (sender, e) =>
{
if(eventArgs.ErrorResponse != null)
{
Console.WriteLine("Error: " + eventArgs.ErrorResponse);
Console.WriteLine("Exception: " + eventArgs.Exception);
}else
{
Console.WriteLine("Error: " + eventArgs.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 + 1, e.TotalChunkCount);
stream.UploadCompleteEvent += (sender, e) => Console.WriteLine("Upload Complete: " + e.FileUrl);
stream.UploadErrorEvent += (sender, e) =>
{
if(eventArgs.ErrorResponse != null)
{
Console.WriteLine("Error: " + eventArgs.ErrorResponse);
Console.WriteLine("Exception: " + eventArgs.Exception);
}else
{
Console.WriteLine("Error: " + eventArgs.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();
}
}
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
- Discord: CraftingDragon007#9504
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Newtonsoft.Json (>= 13.0.1)
- SharpHash_Ron4fun (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.