using System; using System.Text; using System.Linq; using System.Drawing; using System.Diagnostics; using System.Windows.Forms; using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; using Tango.PMR.IO; using Tango.Stubs; using Google.Protobuf; using System.IO; public void OnExecute(StubManager stubManager) { GetStorageInfoRequest getStorageInfoRequest = new GetStorageInfoRequest(); var response = stubManager.Run(getStorageInfoRequest); CreateRequest createRequest = new CreateRequest(); createRequest.Attribute = Tango.PMR.IO.FileAttribute.Directory; createRequest.Path = "0://Shlomo"; var response1 = stubManager.Run(createRequest); DeleteRequest deleteRequest = new DeleteRequest(); deleteRequest.Path = "0://Shlomo//Shlomo1.txt"; var response5 = stubManager.Run(deleteRequest); deleteRequest.Path = "0://Shlomo//Shlomo2.txt"; response5 = stubManager.Run(deleteRequest); createRequest.Attribute = 0; createRequest.Path = "0://Shlomo//Shlomo1.txt"; response1 = stubManager.Run(createRequest); createRequest.Attribute = 0; createRequest.Path = "0://Shlomo//Shlomo2.txt"; response1 = stubManager.Run(createRequest); byte[] fileBytes = File.ReadAllBytes("C:\\FileSystemTests\\test.txt"); FileUploadRequest fileUploadRequest = new FileUploadRequest(); fileUploadRequest.Path = "0://Shlomo//Shlomo1.txt"; fileUploadRequest.Length = (int)fileBytes.Length; FileUploadResponse response2 = stubManager.Run(fileUploadRequest); long chunk_size = response2.MaxChunkLength; FileStream fs = new FileStream("C:\\FileSystemTests\\test.txt",FileMode.Open); while (fs.Position < fs.Length) { stubManager.Write("Position "+ fs.Position+ " Length "+ fs.Length +"\n\n"); FileChunkUploadRequest fileChunkUploadRequest = new FileChunkUploadRequest(); fileChunkUploadRequest.UploadID = response2.UploadID; byte[] chunk = new byte[Math.Min(chunk_size,fs.Length - fs.Position)]; fs.Read(chunk,0,chunk.Length); fileChunkUploadRequest.Path = "0://Shlomo//Shlomo1.txt"; fileChunkUploadRequest.Buffer = ByteString.CopyFrom(chunk); var response3 = stubManager.Run(fileChunkUploadRequest); //Thread.Sleep(2000); } GetFilesRequest getFilesRequest = new GetFilesRequest(); getFilesRequest.Path = "0://Shlomo"; var response4 = stubManager.Run(getFilesRequest); }