示例#1
0
文件: Copy.cs 项目: ywscr/ShareX
        public string CreatePublicURL(string path, CopyURLType urlType = CopyURLType.Default)
        {
            path = path.Trim('/');

            string url = URLHelpers.CombineURL(URLLinks, URLHelpers.URLEncode(path, true));

            string query = OAuthManager.GenerateQuery(url, null, HttpMethod.POST, AuthInfo);

            CopyLinkRequest publicLink = new CopyLinkRequest();

            publicLink.@public = true;
            publicLink.name    = "ShareX";
            publicLink.paths   = new string[] { path };

            string content = JsonConvert.SerializeObject(publicLink);

            string response = SendRequest(HttpMethod.POST, query, content, headers: APIHeaders);

            if (!string.IsNullOrEmpty(response))
            {
                CopyLinksInfo link = JsonConvert.DeserializeObject <CopyLinksInfo>(response);

                return(GetLinkURL(link, path, urlType));
            }

            return("");
        }
示例#2
0
文件: Copy.cs 项目: Maximus325/ShareX
        public string CreatePublicURL(string path, CopyURLType urlType = CopyURLType.Default)
        {
            path = path.Trim('/');

            string url = URLHelpers.CombineURL(URLLinks, URLHelpers.URLPathEncode(path));

            string query = OAuthManager.GenerateQuery(url, null, HttpMethod.POST, AuthInfo);

            CopyLinkRequest publicLink = new CopyLinkRequest();
            publicLink.@public = true;
            publicLink.name = "ShareX";
            publicLink.paths = new string[] { path };

            string content = JsonConvert.SerializeObject(publicLink);

            string response = SendRequest(HttpMethod.POST, query, content, headers: APIHeaders);

            if (!string.IsNullOrEmpty(response))
            {
                CopyLinksInfo link = JsonConvert.DeserializeObject<CopyLinksInfo>(response);

                return GetLinkURL(link, path, urlType);
            }

            return string.Empty;
        }