Esempio n. 1
0
File: Copy.cs Progetto: 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("");
        }
Esempio n. 2
0
File: Copy.cs Progetto: ywscr/ShareX
        public string GetPublicURL(string path, CopyURLType urlType = CopyURLType.Default)
        {
            path = path.Trim('/');

            CopyContentInfo fileInfo = GetMetadata(path);

            foreach (CopyLinksInfo link in fileInfo.links)
            {
                if (!link.expired && link.@public)
                {
                    return(GetLinkURL(link, path, urlType));
                }
            }

            return("");
        }
Esempio n. 3
0
File: Copy.cs Progetto: ywscr/ShareX
        public string GetLinkURL(CopyLinksInfo link, string path, CopyURLType urlType = CopyURLType.Default)
        {
            string filename = URLHelpers.URLEncode(URLHelpers.GetFileName(path));

            switch (urlType)
            {
            default:
            case CopyURLType.Default:
                return(string.Format("https://www.copy.com/s/{0}/{1}", link.id, filename));

            case CopyURLType.Shortened:
                return(string.Format("https://copy.com/{0}", link.id));

            case CopyURLType.Direct:
                return(string.Format("https://copy.com/{0}/{1}", link.id, filename));
            }
        }
Esempio n. 4
0
        public string GetPublicURL(string path, CopyURLType urlType = CopyURLType.Default)
        {
            path = path.Trim('/');

            CopyContentInfo fileInfo = GetMetadata(path);
            foreach (CopyLinksInfo link in fileInfo.links)
            {
                if (!link.expired && link.@public)
                {
                    return GetLinkURL(link, path, urlType);
                }
            }

            return string.Empty;
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
        public string GetLinkURL(CopyLinksInfo link, string path, CopyURLType urlType = CopyURLType.Default)
        {
            string filename = URLHelpers.URLEncode(URLHelpers.GetFileName(path));

            switch (urlType)
            {
                default:
                case CopyURLType.Default:
                    return string.Format("https://www.copy.com/s/{0}/{1}", link.id, filename);
                case CopyURLType.Shortened:
                    return string.Format("https://copy.com/{0}", link.id);
                case CopyURLType.Direct:
                    return string.Format("https://copy.com/{0}/{1}", link.id, filename);
            }
        }