private static void UploadExampleStream() { var testfile = GenFileText(sizeInMb: 32); Dictionary <string, string> metadata = new Dictionary <string, string>(); metadata["filena"] = testfile.Name; TusClient.TusClient tc = new TusClient.TusClient(); tc.Uploading += (long bytesTransferred, long bytesTotal) => { decimal perc = (Decimal)(bytesTransferred / (double)bytesTotal * 100.0); Console.WriteLine("Up {0:0.00}% {1} of {2}", perc, bytesTransferred, bytesTotal); }; var fileURL = tc.Create(ServerURL, testfile.Length, metadata: metadata); using (System.IO.FileStream fs = new System.IO.FileStream(testfile.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read)) { tc.Upload(fileURL, fs); } tc.Delete(fileURL); // Cleanup //System.IO.File.Delete(testfile.FullName); }
private static void UploadExampleMinimal() { var testfile = GenFileText(sizeInMb: 32); TusClient.TusClient tc = new TusClient.TusClient(); tc.Uploading += (long bytesTransferred, long bytesTotal) => { decimal perc = (decimal)(bytesTransferred / (double)bytesTotal * 100.0); Console.WriteLine("Up {0:0.00}% {1} of {2}", perc, bytesTransferred, bytesTotal); }; var fileURL = tc.Create(ServerURL, testfile); tc.Upload(fileURL, testfile); tc.Delete(fileURL); // Cleanup //System.IO.File.Delete(testfile.FullName); }