private void lvFTPList_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(string[]))) { Point point = lvFTPList.PointToClient(new Point(e.X, e.Y)); ListViewItem lvi = lvFTPList.GetItemAt(point.X, point.Y); if (lvi != null && e.AllowedEffect == DragDropEffects.Move) { if (tempSelected != null && tempSelected != lvi) { tempSelected.Selected = false; } FtpListItem file = lvi.Tag as FtpListItem; if (file != null && file.Type == FtpFileSystemObjectType.Directory) { string[] filenames = e.Data.GetData(typeof(string[])) as string[]; if (filenames != null) { int renameCount = 0; foreach (string filename in filenames) { if (file.Name != filename) { string path = URLHelpers.CombineURL(currentDirectory, filename); string movePath = string.Empty; if (file.Type == FtpFileSystemObjectType.Link) { if (file.Name == ".") { movePath = URLHelpers.AddSlash(filename, SlashType.Prefix, 2); } else if (file.Name == "..") { movePath = URLHelpers.AddSlash(filename, SlashType.Prefix); } } else { movePath = URLHelpers.CombineURL(file.FullName, filename); } if (!string.IsNullOrEmpty(movePath)) { Client.Rename(path, movePath); renameCount++; } } } if (renameCount > 0) { RefreshDirectory(); } } } } tempSelected = null; } else if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = e.Data.GetData(DataFormats.FileDrop) as string[]; if (files != null) { Client.UploadFiles(files, currentDirectory); RefreshDirectory(); } } }
public MediaCrushUploader(string apiURL) { APIURL = URLHelpers.FixPrefix(apiURL); }
private void pbSteam_Click(object sender, EventArgs e) { URLHelpers.OpenURL(Links.URL_STEAM); }
public void OpenFile() { if (IsItemSelected && SelectedItem.IsFileExist) URLHelpers.OpenURL(SelectedItem.Info.FilePath); }
public void OpenURL() { if (IsItemSelected && SelectedItem.IsURLExist) URLHelpers.OpenURL(SelectedItem.Info.Result.URL); }
private void pbMikeGooglePlus_Click(object sender, EventArgs e) { URLHelpers.OpenURL(Links.URL_MIKE_GOOGLE_PLUS); }
public override UploadResult Upload(Stream stream, string fileName) { bool isPathStyleRequest = Settings.UsePathStyle; if (!isPathStyleRequest && Settings.Bucket.Contains(".")) { isPathStyleRequest = true; } string endpoint = URLHelpers.RemovePrefixes(Settings.Endpoint); string host = isPathStyleRequest ? endpoint : $"{Settings.Bucket}.{endpoint}"; string algorithm = "AWS4-HMAC-SHA256"; string credentialDate = DateTime.UtcNow.ToString("yyyyMMdd", CultureInfo.InvariantCulture); string region = GetRegion(); string scope = URLHelpers.CombineURL(credentialDate, region, "s3", "aws4_request"); string credential = URLHelpers.CombineURL(Settings.AccessKeyID, scope); string timeStamp = DateTime.UtcNow.ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture); string contentType = Helpers.GetMimeType(fileName); string hashedPayload = "UNSIGNED-PAYLOAD"; if ((Settings.RemoveExtensionImage && Helpers.IsImageFile(fileName)) || (Settings.RemoveExtensionText && Helpers.IsTextFile(fileName)) || (Settings.RemoveExtensionVideo && Helpers.IsVideoFile(fileName))) { fileName = Path.GetFileNameWithoutExtension(fileName); } string uploadPath = GetUploadPath(fileName); NameValueCollection headers = new NameValueCollection { ["Host"] = host, ["Content-Length"] = stream.Length.ToString(), ["Content-Type"] = contentType, ["x-amz-date"] = timeStamp, ["x-amz-content-sha256"] = hashedPayload, ["x-amz-storage-class"] = Settings.StorageClass.ToString() }; if (Settings.SetPublicACL) { headers["x-amz-acl"] = "public-read"; } string canonicalURI = uploadPath; if (isPathStyleRequest) { canonicalURI = URLHelpers.CombineURL(Settings.Bucket, canonicalURI); } canonicalURI = URLHelpers.AddSlash(canonicalURI, SlashType.Prefix); canonicalURI = URLHelpers.URLPathEncode(canonicalURI); string canonicalQueryString = ""; string canonicalHeaders = CreateCanonicalHeaders(headers); string signedHeaders = GetSignedHeaders(headers); string canonicalRequest = "PUT" + "\n" + canonicalURI + "\n" + canonicalQueryString + "\n" + canonicalHeaders + "\n" + signedHeaders + "\n" + hashedPayload; string stringToSign = algorithm + "\n" + timeStamp + "\n" + scope + "\n" + Helpers.BytesToHex(Helpers.ComputeSHA256(canonicalRequest)); byte[] dateKey = Helpers.ComputeHMACSHA256(credentialDate, "AWS4" + Settings.SecretAccessKey); byte[] dateRegionKey = Helpers.ComputeHMACSHA256(region, dateKey); byte[] dateRegionServiceKey = Helpers.ComputeHMACSHA256("s3", dateRegionKey); byte[] signingKey = Helpers.ComputeHMACSHA256("aws4_request", dateRegionServiceKey); string signature = Helpers.BytesToHex(Helpers.ComputeHMACSHA256(stringToSign, signingKey)); headers["Authorization"] = algorithm + " " + "Credential=" + credential + "," + "SignedHeaders=" + signedHeaders + "," + "Signature=" + signature; headers.Remove("Host"); headers.Remove("Content-Type"); string url = URLHelpers.CombineURL(host, canonicalURI); url = URLHelpers.ForcePrefix(url, "https://"); NameValueCollection responseHeaders = SendRequestGetHeaders(HttpMethod.PUT, url, stream, contentType, null, headers); if (responseHeaders == null || responseHeaders.Count == 0 || responseHeaders["ETag"] == null) { Errors.Add("Upload to Amazon S3 failed."); return(null); } return(new UploadResult { IsSuccess = true, URL = GenerateURL(uploadPath) }); }
private void llAttribution_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { URLHelpers.OpenURL("https://ocr.space"); }
private void llGoogleTranslate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { URLHelpers.OpenURL("https://translate.google.com/#auto/en/" + Uri.EscapeDataString(txtResult.Text)); this.Close(); }
public string GetUriPath(string filename, string subFolderPath = null) { if (string.IsNullOrEmpty(Host)) { return(""); } if (HttpHomePathNoExtension) { filename = Path.GetFileNameWithoutExtension(filename); } filename = URLHelpers.URLEncode(filename); if (subFolderPath == null) { subFolderPath = GetSubFolderPath(); } UriBuilder httpHomeUri; string httpHomePath = GetHttpHomePath(); if (string.IsNullOrEmpty(httpHomePath)) { string host = Host; if (host.StartsWith("ftp.")) { host = host.Substring(4); } httpHomeUri = new UriBuilder(URLHelpers.CombineURL(host, subFolderPath, filename)); httpHomeUri.Port = -1; //Since httpHomePath is not set, it's safe to erase UriBuilder's assumed port number } else { //Parse HttpHomePath in to host, port, path and query components int firstSlash = httpHomePath.IndexOf('/'); string httpHome = firstSlash >= 0 ? httpHomePath.Substring(0, firstSlash) : httpHomePath; int portSpecifiedAt = httpHome.LastIndexOf(':'); string httpHomeHost = portSpecifiedAt >= 0 ? httpHome.Substring(0, portSpecifiedAt) : httpHome; int httpHomePort = -1; string httpHomePathAndQuery = firstSlash >= 0 ? httpHomePath.Substring(firstSlash + 1) : ""; int querySpecifiedAt = httpHomePathAndQuery.LastIndexOf('?'); string httpHomeDir = querySpecifiedAt >= 0 ? httpHomePathAndQuery.Substring(0, querySpecifiedAt) : httpHomePathAndQuery; string httpHomeQuery = querySpecifiedAt >= 0 ? httpHomePathAndQuery.Substring(querySpecifiedAt + 1) : ""; if (portSpecifiedAt >= 0) { int.TryParse(httpHome.Substring(portSpecifiedAt + 1), out httpHomePort); } //Build URI httpHomeUri = new UriBuilder { Host = httpHomeHost, Path = httpHomeDir, Query = httpHomeQuery }; if (portSpecifiedAt >= 0) { httpHomeUri.Port = httpHomePort; } if (httpHomeUri.Query.EndsWith("=")) { //Setting URIBuilder.Query automatically prepends a ? so we must trim it first. if (HttpHomePathAutoAddSubFolderPath) { httpHomeUri.Query = URLHelpers.CombineURL(httpHomeUri.Query.Substring(1), subFolderPath, filename); } else { httpHomeUri.Query = httpHomeUri.Query.Substring(1) + filename; } } else { if (HttpHomePathAutoAddSubFolderPath) { httpHomeUri.Path = URLHelpers.CombineURL(httpHomeUri.Path, subFolderPath); } httpHomeUri.Path = URLHelpers.CombineURL(httpHomeUri.Path, filename); } } httpHomeUri.Scheme = BrowserProtocol.GetDescription(); return(httpHomeUri.Uri.AbsoluteUri); }
private void llTranslators_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { URLHelpers.OpenURL("https://github.com/ShareX/ShareX/wiki/Translation"); }
public string GetSubFolderPath(string filename = null, NameParserType nameParserType = NameParserType.URL) { string path = NameParser.Parse(nameParserType, SubFolderPath.Replace("%host", Host)); return(URLHelpers.CombineURL(path, filename)); }
public bool ShouldSerializeName() => !string.IsNullOrEmpty(Name) && Name != URLHelpers.GetHostName(RequestURL);
public override string ToString() { return(URLHelpers.GetHostName(UploadURL)); }
private void pbBerkSteamURL_Click(object sender, EventArgs e) { URLHelpers.OpenURL(Links.URL_BERK_STEAM); }
private void btnChromeOpenExtensionPage_Click(object sender, EventArgs e) { URLHelpers.OpenURL("https://chrome.google.com/webstore/detail/sharex/nlkoigbdolhchiicbonbihbphgamnaoc"); }
private void pbMikeURL_Click(object sender, EventArgs e) { URLHelpers.OpenURL(Links.URL_MIKE); }
private void btnFirefoxOpenAddonPage_Click(object sender, EventArgs e) { URLHelpers.OpenURL("https://addons.mozilla.org/en-US/firefox/addon/sharex/"); }
private void rtb_LinkClicked(object sender, LinkClickedEventArgs e) { URLHelpers.OpenURL(e.LinkText); }
private void btnHelperDevicesHelp_Click(object sender, EventArgs e) { URLHelpers.OpenURL("https://github.com/rdp/screen-capture-recorder-to-video-windows-free"); }
private string GetUploadPath(string fileName) { string path = NameParser.Parse(NameParserType.FolderPath, Settings.ObjectPrefix.Trim('/')); return(URLHelpers.CombineURL(path, fileName)); }
private void buttonFFmpegHelp_Click(object sender, EventArgs e) { URLHelpers.OpenURL("https://github.com/ShareX/ShareX/wiki/FFmpeg-options#additional-commands"); }
public void OpenThumbnailFile() { if (IsItemSelected && SelectedItem.IsThumbnailFileExist) URLHelpers.OpenURL(SelectedItem.Info.ThumbnailFilePath); }
private void btnHelp_Click(object sender, EventArgs e) { URLHelpers.OpenURL("https://github.com/ShareX/ShareX/wiki/FFmpeg-options"); }
public static void ClipboardUpload(TaskSettings taskSettings = null) { if (taskSettings == null) { taskSettings = TaskSettings.GetDefaultTaskSettings(); } if (Clipboard.ContainsImage()) { Image img = ClipboardHelpers.GetImage(); if (img != null) { if (!taskSettings.AdvancedSettings.ProcessImagesDuringClipboardUpload) { taskSettings.AfterCaptureJob = AfterCaptureTasks.UploadImageToHost; } RunImageTask(img, taskSettings); } } else if (Clipboard.ContainsText()) { string text = Clipboard.GetText(); if (!string.IsNullOrEmpty(text)) { string url = text.Trim(); if (URLHelpers.IsValidURL(url)) { if (taskSettings.UploadSettings.ClipboardUploadURLContents) { DownloadAndUploadFile(url, taskSettings); return; } if (taskSettings.UploadSettings.ClipboardUploadShortenURL) { ShortenURL(url, taskSettings); return; } if (taskSettings.UploadSettings.ClipboardUploadShareURL) { ShareURL(url, taskSettings); return; } } if (taskSettings.UploadSettings.ClipboardUploadAutoIndexFolder && text.Length <= 260 && Directory.Exists(text)) { IndexFolder(text, taskSettings); } else { UploadText(text, taskSettings, true); } } } else if (Clipboard.ContainsFileDropList()) { string[] files = Clipboard.GetFileDropList().OfType <string>().ToArray(); if (files.Length > 0) { UploadFile(files, taskSettings); } } }
public string GetAuthorizationURL() { return(string.Format("https://accounts.google.com/o/oauth2/auth?response_type={0}&client_id={1}&redirect_uri={2}&scope={3}", "code", AuthInfo.Client_ID, "urn:ietf:wg:oauth:2.0:oob", URLHelpers.URLEncode("https://www.googleapis.com/auth/drive"))); }
public override UploadResult Upload(Stream stream, string fileName) { WebExceptionThrow = true; string hash = CreateHash(stream); UploadResult result = CheckExists(hash); if (result != null) { return(result); } try { result = SendRequestFile(URLHelpers.CombineURL(APIURL, "api/upload/file"), stream, fileName); } catch (WebException e) { HttpWebResponse response = e.Response as HttpWebResponse; if (response == null) { throw; } if (response.StatusCode == HttpStatusCode.Conflict) { return(HandleDuplicate(response)); } throw; } hash = JToken.Parse(result.Response)["hash"].Value <string>(); while (!StopUploadRequested) { result.Response = SendRequest(HttpMethod.GET, URLHelpers.CombineURL(APIURL, "api/" + hash + "/status")); JToken jsonResponse = JToken.Parse(result.Response); string status = jsonResponse["status"].Value <string>(); switch (status) { case "processing": case "pending": Thread.Sleep(500); break; case "done": case "ready": MediaCrushBlob blob = jsonResponse[hash].ToObject <MediaCrushBlob>(); return(UpdateResult(result, blob)); case "unrecognized": // Note: MediaCrush accepts just about _every_ kind of media file, // so the file itself is probably corrupted or just not actually a media file throw new Exception("This file is not an acceptable file type."); case "timeout": throw new Exception("This file took too long to process."); default: throw new Exception("This file failed to process."); } } return(result); }
private void lblProductName_Click(object sender, EventArgs e) { URLHelpers.OpenURL(Links.URL_VERSION_HISTORY); }
private void pbJaexURL_Click(object sender, EventArgs e) { URLHelpers.OpenURL(Links.URL_JAEX); }
public override UploadResult Upload(Stream stream, string fileName) { string hostname = URLHelpers.RemovePrefixes(Settings.RegionHostname); string host = $"{Settings.Bucket}.{hostname}"; string algorithm = "AWS4-HMAC-SHA256"; string credentialDate = DateTime.UtcNow.ToString("yyyyMMdd", CultureInfo.InvariantCulture); string scope = $"{credentialDate}/{Settings.RegionIdentifier}/s3/aws4_request"; string credential = $"{Settings.AccessKeyID}/{scope}"; string longDate = DateTime.UtcNow.ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture); string expiresTotalSeconds = ((long)TimeSpan.FromHours(1).TotalSeconds).ToString(); string contentType = Helpers.GetMimeType(fileName); NameValueCollection headers = new NameValueCollection(); headers["content-type"] = contentType; headers["host"] = host; headers["x-amz-acl"] = "public-read"; headers["x-amz-storage-class"] = Settings.UseReducedRedundancyStorage ? "REDUCED_REDUNDANCY" : "STANDARD"; string signedHeaders = GetSignedHeaders(headers); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("X-Amz-Algorithm", algorithm); args.Add("X-Amz-Credential", credential); args.Add("X-Amz-Date", longDate); args.Add("X-Amz-Expires", expiresTotalSeconds); args.Add("X-Amz-SignedHeaders", signedHeaders); string uploadPath = GetUploadPath(fileName); string canonicalURI = URLHelpers.AddSlash(uploadPath, SlashType.Prefix); canonicalURI = URLHelpers.URLPathEncode(canonicalURI); string canonicalQueryString = CreateQueryString(args); string canonicalHeaders = CreateCanonicalHeaders(headers); string canonicalRequest = "PUT" + "\n" + canonicalURI + "\n" + canonicalQueryString + "\n" + canonicalHeaders + "\n" + signedHeaders + "\n" + "UNSIGNED-PAYLOAD"; string stringToSign = algorithm + "\n" + longDate + "\n" + scope + "\n" + BytesToHex(ComputeHash(canonicalRequest)); byte[] secretKey = Encoding.UTF8.GetBytes("AWS4" + Settings.SecretAccessKey); byte[] dateKey = ComputeHMAC(Encoding.UTF8.GetBytes(credentialDate), secretKey); byte[] dateRegionKey = ComputeHMAC(Encoding.UTF8.GetBytes(Settings.RegionIdentifier), dateKey); byte[] dateRegionServiceKey = ComputeHMAC(Encoding.UTF8.GetBytes("s3"), dateRegionKey); byte[] signingKey = ComputeHMAC(Encoding.UTF8.GetBytes("aws4_request"), dateRegionServiceKey); string signature = BytesToHex(ComputeHMAC(Encoding.UTF8.GetBytes(stringToSign), signingKey)); args.Add("X-Amz-Signature", signature); headers.Remove("content-type"); headers.Remove("host"); string url = URLHelpers.CombineURL(host, canonicalURI) + "?" + CreateQueryString(args); url = URLHelpers.ForcePrefix(url, "https://"); NameValueCollection responseHeaders = SendRequestGetHeaders(HttpMethod.PUT, url, stream, contentType, null, headers); if (responseHeaders == null || responseHeaders.Count == 0) { Errors.Add("Upload to Amazon S3 failed. Check your access credentials."); return(null); } if (responseHeaders["ETag"] == null) { Errors.Add("Upload to Amazon S3 failed."); return(null); } return(new UploadResult { IsSuccess = true, URL = GenerateURL(fileName) }); }