/plikSharp

A .NET API client for Plik, the scalable & friendly temporary file upload system, written in C#

Primary LanguageC#MIT LicenseMIT

Build status NuGet version License

plikSharp

A .NET API client for Plik, the scalable & friendly temporary file upload system, written in C#. The API client is available at NuGet for .NETFramework >=4.5 and .NETStandard >=2.0.

Acknowledgements

  • Plik - The scalable & friendly temporary file upload system ( wetransfer like ) in golang
  • Refit - The automatic type-safe REST library for Xamarin and .NET

Examples

// Create client
var plikApi = RestService.For<IPlikApi>("http://localhost");

// Create a new upload, set properties as needed
var upload = await plikApi.CreateUploadAsync(new UploadRequest
{
   OneShot = false,
   Removable = true
});

using (var file = System.IO.File.OpenRead("test.txt"))
{
   // Add a file to the created upload
   var uploadedFile = await plikApi.UploadFileAsync(upload.Id, upload.UploadToken, new StreamPart(file, "test.txt"));    
}
// Download a file
var downloadResult = await plikApi.GetFileAsync(upload.Id, uploadedFile.Id, uploadedFile.FileName);
var fileBytes = await downloadResult.ReadAsByteArrayAsync();
// Download all files as zip
var zipDownloadResult = await plikApi.GetArchiveAsync(upload.Id, "wholething.zip");
// Delete a file
var uploadMetaData = await plikApi.DeleteFileAsync(upload.Id, fileId, fileName);