public static string ExecuteUploadAndReturnExitCode(UploadOptions options) { var file = new FileInfo($"{options.Directory}+{options.FileName}"); Console.WriteLine($"Uploading {file.FullName}"); Console.WriteLine($"Password: {options.Password}"); return(Api.Upload(options) == true? "File was properly uploaded":"File was not uploaded properly"); }
public static int ExecuteUploadAndReturnExitCode(UploadOptions options) { // TODO var file = new FileInfo(options.FileName); Console.WriteLine($"Uploading {file.FullName}"); Console.WriteLine($"Password: {options.Password}"); return(0); }
public static int ExecuteUploadAndReturnExitCode(UploadOptions options) { foreach (var filename in options.Filenames) { var file = new FileInfo(filename); if (!file.Exists) { Console.WriteLine(Client.Config.MessageFileNotFound, filename); return(Client.Config.ResultFailure); } } return((Api.Upload(options)) ? Client.Config.ResultSuccess : Client.Config.ResultFailure); }
public static int ExecuteUploadAndReturnExitCode(UploadOptions options) { // TODO try { XmlSerializer Serializer = new XmlSerializer(typeof(ClientToServerDTO)); FileInfo file = new FileInfo(options.FileName); ClientToServerDTO toServerDTO = new ClientToServerDTO { Filename = options.FileName, Password = options.Password, MaxDown = options.MaximumDownloads, Created = DateTime.Now.ToString(), UserAction = UserAction.upload, Expiration = DateTime.Now.AddMinutes(options.Expiration).ToString() }; FileStream Upload = new FileStream(file.FullName, FileMode.Open, FileAccess.ReadWrite); toServerDTO.FileData = new byte[Upload.Length]; Upload.Read(toServerDTO.FileData, 0, (int)Upload.Length); // TCP - Internet Connection TcpClient clientConnection = new TcpClient("127.0.0.1", 1234); using (NetworkStream stream = clientConnection.GetStream()) { Serializer.Serialize(stream, toServerDTO); } Console.WriteLine($"Uploading {options.FileName}"); Console.WriteLine($"Repository Access Password: {options.Password}"); } catch (Exception e) { Console.WriteLine(e.Message); } return(0); }
public static int ExecuteUploadAndReturnExitCode(UploadOptions options) { try { // Fetch data from FileStream and put into byte array using (FileStream fileSource = new FileStream(options.FileName, FileMode.Open, FileAccess.Read)) { byte[] bytes = new byte[fileSource.Length]; int n = fileSource.Read(bytes); // Building client uploadrequest var request = new FileRequest { Action = Core.Action.upload, Filename = options.FileName, TheFile = bytes, Password = options.Password, TimeCreated = DateTime.Now, MaxDownload = options.MaxDownloads, Expiration = options.Expiration, TotalDownload = 0, }; var file = new FileInfo(options.FileName); Console.WriteLine($"Uploading {file.FullName}"); Console.WriteLine($"Password: {options.Password}"); Console.WriteLine($"Maxinmum Download: {options.MaxDownloads}"); Api.Upload(request); } } catch (IOException e) { Console.WriteLine(e.Message); } return(0); }