private string UploadScreenshot(Bitmap bitmap) { try { return(UploaderFactory.Create(Settings.Current.UploaderType).Upload(bitmap)); } catch { return(null); } }
public ProgressForm(UploadFile[] files, string url, string user, string password) { InitializeComponent(); this.files = files; this.url = url; this.user = user; this.password = password; total = 0; currentBytes = 0; ques = new Queue <UploadFile>(files); uploader = UploaderFactory.CreateInstance(); currentPercent = 0; }
public UploadResult ShortenURL(string url) { URLShortenerService service = UploaderFactory.GetURLShortenerService(Info.TaskSettings.URLShortenerDestination); if (!service.CheckConfig(Program.UploadersConfig)) { return(GetInvalidConfigResult(service)); } URLShortener urlShortener = service.CreateShortener(Program.UploadersConfig, taskReferenceHelper); if (urlShortener != null) { return(urlShortener.ShortenURL(url)); } return(null); }
public UploadResult ShareURL(string url) { if (!string.IsNullOrEmpty(url)) { URLSharingService service = UploaderFactory.GetURLSharingService(Info.TaskSettings.URLSharingServiceDestination); if (!service.CheckConfig(Program.UploadersConfig)) { return(GetInvalidConfigResult(service)); } service.ShareURL(url, Program.UploadersConfig); return(new UploadResult() { URL = url }); } return(null); }
private bool InvokeUpload(string destFileName, string localFileName, int chunkSize) { WebUploader uploader = UploaderFactory.GetWebUploader(new TransferParameter() { ChunkSize = chunkSize, Environment = _environment, LocalFile = localFileName, RemoteFile = destFileName, TransferUrl = UploadUrl, SupportBrokenResume = _supportBorkenResume, SupportDebug = _supportDebug, FileDirectory = FileDirectory }); if (uploader != null) { try { bool hasFinished = false; bool hasException = false; uploader.Completed += new CompletedEventHandler(OnCompleted); uploader.Completed += new CompletedEventHandler(delegate(object sender, CompletedEventArgs args) { hasFinished = true; }); uploader.Progress += new ProgressEventHandle(OnProgress); uploader.ExceptionError += new ExceptionEventHandle(delegate(object sender, ExceptionEventArgs args) { hasException = hasFinished = true; }); uploader.ExceptionError += new ExceptionEventHandle(OnException); uploader.Start(); while (!hasFinished) { Thread.Sleep(100); } if (hasException) { Log.Debug("文件上传遇到问题"); _errmsg = uploader.InnerException.Message; throw uploader.InnerException; } return(true); } catch (Exception ex) { _errmsg = ex.Message; throw new Exception("InvokeUpload error"); } } return(false); }
public void SftpUpload() { try { using (var session = new Session()) { Console.WriteLine("Connecting the server..."); var uploader = UploaderFactory.GetUploader(_config); session.Open(uploader.GetSessionOptions()); if (session.Opened) { Util.DisplayDone(TextCollection.Const.DoneSftpConnected); Console.WriteLine(TextCollection.Const.InfoFileUploading); var remotePath = uploader.SetupRemotePath(); var transferOptions = uploader.SetupTransferOptions(); uploader.Prepare(); Console.WriteLine("Uploading..."); uploader.UploadLocalFile(session, remotePath, transferOptions); Util.DisplayDone(TextCollection.Const.DoneUploaded); uploader.CleanUp(); } else { Util.DisplayWarning(TextCollection.Const.ErrorNetworkFailed, new InvalidOperationException()); } } } catch (Exception e) { Console.WriteLine("Error during SFTP uploading: {0}", e); Util.DisplayWarning(TextCollection.Const.ErrorNetworkFailed, e); } }
public UploadResult UploadFile(Stream stream, string fileName) { FileUploaderService service = UploaderFactory.GetFileUploaderService(Info.TaskSettings.GetFileDestinationByDataType(Info.DataType)); return(UploadData(service, stream, fileName)); }
public UploadResult UploadText(Stream stream, string fileName) { TextUploaderService service = UploaderFactory.GetTextUploaderService(Info.TaskSettings.TextDestination); return(UploadData(service, stream, fileName)); }
public UploadResult UploadImage(Stream stream, string fileName) { ImageUploaderService service = UploaderFactory.GetImageUploaderService(Info.TaskSettings.ImageDestination); return(UploadData(service, stream, fileName)); }
public Processor() { _uploader = UploaderFactory.Create(Settings.Current.UploaderType); Settings.Current.Apply(); }