예제 #1
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("key", APIKey);
            args.Add("format", "json");

            string url = URLHelpers.FixPrefix(Website);

            url = URLHelpers.CombineURL(url, "api/1/upload");

            UploadResult result = UploadData(stream, url, fileName, "source", args);

            if (result.IsSuccess)
            {
                CheveretoResponse response = JsonConvert.DeserializeObject <CheveretoResponse>(result.Response);

                if (response != null && response.Image != null)
                {
                    result.URL = DirectURL ? response.Image.URL : response.Image.URL_Viewer;

                    if (response.Image.Thumb != null)
                    {
                        result.ThumbnailURL = response.Image.Thumb.URL;
                    }
                }
            }

            return(result);
        }
예제 #2
0
        private string GetObjectURL(string objectName)
        {
            objectName = objectName.Trim('/');
            objectName = URLHelpers.URLPathEncode(objectName);

            string url = string.Empty;

            if (S3Settings.UseCustomCNAME)
            {
                if (!string.IsNullOrEmpty(S3Settings.CustomDomain))
                {
                    url = URLHelpers.CombineURL(S3Settings.CustomDomain, objectName);
                }
                else
                {
                    url = URLHelpers.CombineURL(S3Settings.Bucket, objectName);
                }
            }
            else
            {
                url = URLHelpers.CombineURL(GetEndpoint(), objectName);
            }

            url = URLHelpers.FixPrefix(url);

            return(url);
        }
예제 #3
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("key", Uploader.APIKey);
            args.Add("format", "json");

            string url = URLHelpers.FixPrefix(Uploader.UploadURL);

            UploadResult result = SendRequestFile(url, stream, fileName, "source", args);

            if (result.IsSuccess)
            {
                CheveretoResponse response = JsonConvert.DeserializeObject <CheveretoResponse>(result.Response);

                if (response != null && response.Image != null)
                {
                    result.URL = DirectURL ? response.Image.URL : response.Image.URL_Viewer;

                    if (response.Image.Thumb != null)
                    {
                        result.ThumbnailURL = response.Image.Thumb.URL;
                    }
                }
            }

            return(result);
        }
예제 #4
0
        public bool CheckAPIURL()
        {
            string url = URLHelpers.FixPrefix(APIURL);

            url = URLHelpers.CombineURL(APIURL, "ping/?format=json");

            SSLBypassHelper sslBypassHelper = null;

            try
            {
                if (IgnoreInvalidCert)
                {
                    sslBypassHelper = new SSLBypassHelper();
                }

                string response = SendRequest(HttpMethod.GET, url);

                if (!string.IsNullOrEmpty(response))
                {
                    if (response == "\"pong\"")
                    {
                        return(true);
                    }
                }

                return(false);
            }
            finally
            {
                if (sslBypassHelper != null)
                {
                    sslBypassHelper.Dispose();
                }
            }
        }
예제 #5
0
        public override UploadResult ShortenURL(string url)
        {
            UploadResult result = new UploadResult {
                URL = url
            };

            if (string.IsNullOrEmpty(API_HOST))
            {
                API_HOST = "https://polr.me/publicapi.php";
                API_KEY  = null;
            }
            else
            {
                API_HOST = URLHelpers.FixPrefix(API_HOST);
            }

            Dictionary <string, string> args = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(API_KEY))
            {
                args.Add("apikey", API_KEY);
            }

            args.Add("action", "shorten");
            args.Add("url", url);

            string response = SendRequest(HttpMethod.GET, API_HOST, args);

            if (!string.IsNullOrEmpty(response))
            {
                result.ShortenedURL = response;
            }

            return(result);
        }
예제 #6
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (string.IsNullOrEmpty(Host))
            {
                throw new Exception("ownCloud Host is empty.");
            }

            if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
            {
                throw new Exception("ownCloud Username or Password is empty.");
            }

            if (string.IsNullOrEmpty(Path))
            {
                Path = "/";
            }

            string path = URLHelpers.CombineURL(Path, fileName);
            string url  = URLHelpers.CombineURL(Host, "remote.php/webdav", path);

            url = URLHelpers.FixPrefix(url);
            NameValueCollection headers = CreateAuthenticationHeader(Username, Password);

            SSLBypassHelper sslBypassHelper = null;

            try
            {
                if (IgnoreInvalidCert)
                {
                    sslBypassHelper = new SSLBypassHelper();
                }

                string response = SendRequestStream(url, stream, Helpers.GetMimeType(fileName), headers, method: HttpMethod.PUT);

                UploadResult result = new UploadResult(response);

                if (!IsError)
                {
                    if (CreateShare)
                    {
                        AllowReportProgress = false;
                        result.URL          = ShareFile(path);
                    }
                    else
                    {
                        result.IsURLExpected = false;
                    }
                }

                return(result);
            }
            finally
            {
                if (sslBypassHelper != null)
                {
                    sslBypassHelper.Dispose();
                }
            }
        }
예제 #7
0
        public string GetRequestURL()
        {
            if (string.IsNullOrEmpty(RequestURL))
            {
                throw new Exception("'Request URL' must be not empty.");
            }

            return(URLHelpers.FixPrefix(RequestURL));
        }
예제 #8
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (string.IsNullOrEmpty(Host))
            {
                throw new Exception("PutWebDav Host is empty.");
            }

            if (string.IsNullOrEmpty(Port))
            {
                Port = "443";
            }

            if (string.IsNullOrEmpty(Directory))
            {
                Directory = "/";
            }

            if (string.IsNullOrEmpty(BaseURL))
            {
                BaseURL = URLHelpers.CombineURL(Host, ":", Port, Directory);
            }

            Filename = fileName;

            // Original, unencoded path. Necessary for shared files
            string path = URLHelpers.CombineURL(Directory, fileName);
            // Encoded path, necessary when sent in the URL
            string encodedPath = URLHelpers.CombineURL(Directory, URLHelpers.URLEncode(fileName));

            string url = URLHelpers.CombineURL(Host, encodedPath);

            url = URLHelpers.FixPrefix(url);

            //NameValueCollection headers = UploadHelpers.CreateAuthenticationHeader(Username, Password);
            //headers["OCS-APIREQUEST"] = "true";

            string response = SendRequest(HttpMethod.PUT, url, stream, UploadHelpers.GetMimeType(fileName), null, null);

            UploadResult result = new UploadResult(response);

            if (!IsError)
            {
                if (CreateShare)
                {
                    AllowReportProgress = false;
                    result.URL          = ShareFile(path);
                }
                else
                {
                    result.IsURLExpected = false;
                }
            }

            return(result);
        }
예제 #9
0
        public string GetRequestURL()
        {
            if (string.IsNullOrEmpty(RequestURL))
            {
                throw new Exception("'Request URL' must be not empty.");
            }

            string url = ParseURL(RequestURL, false);

            return(URLHelpers.FixPrefix(url));
        }
예제 #10
0
        public string GetRequestURL()
        {
            if (string.IsNullOrEmpty(RequestURL))
            {
                throw new Exception(Resources.CustomUploaderItem_GetRequestURL_RequestURLMustBeConfigured);
            }

            string url = ParseURL(RequestURL, false);

            return(URLHelpers.FixPrefix(url));
        }
예제 #11
0
        public string GetRequestURL()
        {
            if (string.IsNullOrEmpty(RequestURL))
            {
                throw new Exception(Resources.CustomUploaderItem_GetRequestURL_RequestURLMustBeConfigured);
            }

            CustomUploaderParser parser = new CustomUploaderParser();
            string url = parser.Parse(RequestURL);

            return(URLHelpers.FixPrefix(url));
        }
예제 #12
0
        // http://doc.owncloud.org/server/7.0/developer_manual/core/ocs-share-api.html#create-a-new-share
        public string ShareFile(string path)
        {
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("path", path);     // path to the file/folder which should be shared
            args.Add("shareType", "3"); // ‘0’ = user; ‘1’ = group; ‘3’ = public link
            // args.Add("shareWith", ""); // user / group id with which the file should be shared
            // args.Add("publicUpload", "false"); // allow public upload to a public shared folder (true/false)
            // args.Add("password", ""); // password to protect public link Share with
            args.Add("permissions", "1"); // 1 = read; 2 = update; 4 = create; 8 = delete; 16 = share; 31 = all (default: 31, for public shares: 1)

            string url = URLHelpers.CombineURL(Host, "ocs/v1.php/apps/files_sharing/api/v1/shares?format=json");

            url = URLHelpers.FixPrefix(url);

            NameValueCollection headers = CreateAuthenticationHeader(Username, Password);

            headers["OCS-APIREQUEST"] = "true";

            string response = SendRequestMultiPart(url, args, headers);

            if (!string.IsNullOrEmpty(response))
            {
                OwnCloudShareResponse result = JsonConvert.DeserializeObject <OwnCloudShareResponse>(response);

                if (result != null && result.ocs != null && result.ocs.meta != null)
                {
                    if (result.ocs.data != null && result.ocs.meta.statuscode == 100)
                    {
                        OwnCloudShareResponseData data = ((JObject)result.ocs.data).ToObject <OwnCloudShareResponseData>();
                        string link = data.url;
                        if (PreviewLink)
                        {
                            if (Helpers.IsImageFile(path))
                            {
                                link += "/preview";
                            }
                        }
                        else if (DirectLink)
                        {
                            link += (IsCompatibility81 ? "/" : "&") + "download";
                        }
                        return(link);
                    }
                    else
                    {
                        Errors.Add(string.Format("Status: {0}\r\nStatus code: {1}\r\nMessage: {2}", result.ocs.meta.status, result.ocs.meta.statuscode, result.ocs.meta.message));
                    }
                }
            }

            return(null);
        }
예제 #13
0
        public string GetRequestURL()
        {
            if (string.IsNullOrEmpty(RequestURL))
            {
                // TODO: Translate
                throw new Exception("\"Request URL\" must be configured.");
            }

            string url = ParseURL(RequestURL, false);

            return(URLHelpers.FixPrefix(url));
        }
예제 #14
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (string.IsNullOrEmpty(Host))
            {
                throw new Exception("ownCloud Host is empty.");
            }

            if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
            {
                throw new Exception("ownCloud Username or Password is empty.");
            }

            if (string.IsNullOrEmpty(Path))
            {
                Path = "/";
            }

            // Original, unencoded path. Necessary for shared files
            string path = URLHelpers.CombineURL(Path, fileName);
            // Encoded path, necessary when sent in the URL
            string encodedPath = URLHelpers.CombineURL(Path, URLHelpers.URLEncode(fileName));

            string url = URLHelpers.CombineURL(Host, "remote.php/webdav", encodedPath);

            url = URLHelpers.FixPrefix(url);

            NameValueCollection headers = RequestHelpers.CreateAuthenticationHeader(Username, Password);

            headers["OCS-APIREQUEST"] = "true";

            string response = SendRequest(HttpMethod.PUT, url, stream, RequestHelpers.GetMimeType(fileName), null, headers);

            UploadResult result = new UploadResult(response);

            if (!IsError)
            {
                if (CreateShare)
                {
                    AllowReportProgress = false;
                    result.URL          = ShareFile(path);
                }
                else
                {
                    result.IsURLExpected = false;
                }
            }

            return(result);
        }
예제 #15
0
        public bool DecryptLibrary(string libraryPassword)
        {
            string url = URLHelpers.FixPrefix(APIURL);

            url = URLHelpers.CombineURL(APIURL, "repos/" + RepoID + "/?format=json");

            NameValueCollection headers = new NameValueCollection();

            headers.Add("Authorization", "Token " + AuthToken);

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("password", libraryPassword);

            SSLBypassHelper sslBypassHelper = null;

            try
            {
                if (IgnoreInvalidCert)
                {
                    sslBypassHelper = new SSLBypassHelper();
                }

                string response = SendRequest(HttpMethod.POST, url, args, headers);

                if (!string.IsNullOrEmpty(response))
                {
                    if (response == "\"success\"")
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(false);
            }
            finally
            {
                if (sslBypassHelper != null)
                {
                    sslBypassHelper.Dispose();
                }
            }
        }
예제 #16
0
        private void B2UpdateCustomDomainPreview()
        {
            string uploadPath = NameParser.Parse(NameParserType.FilePath, Config.B2UploadPath);
            string url;

            if (cbB2CustomUrl.Checked)
            {
                url = URLHelpers.CombineURL(Config.B2CustomUrl, uploadPath, "example.png");
                url = URLHelpers.FixPrefix(url, "https://");
            }
            else
            {
                string bucket = string.IsNullOrEmpty(Config.B2BucketName) ? "[bucket]" : URLHelpers.URLEncode(Config.B2BucketName);
                url = URLHelpers.CombineURL("https://f001.backblazeb2.com/file", bucket, uploadPath, "example.png");
            }

            lblB2UrlPreview.Text = url;
        }
예제 #17
0
        public string GenerateURL(string uploadPath)
        {
            if (string.IsNullOrEmpty(Bucket))
            {
                return("");
            }

            if (string.IsNullOrEmpty(Domain))
            {
                Domain = URLHelpers.CombineURL("storage.googleapis.com", Bucket);
            }

            uploadPath = URLHelpers.URLEncode(uploadPath, true);

            string url = URLHelpers.CombineURL(Domain, uploadPath);

            return(URLHelpers.FixPrefix(url, "https://"));
        }
예제 #18
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (!CheckAuthorization())
            {
                return(null);
            }

            string uploadpath = GetUploadPath(fileName);

            if (string.IsNullOrEmpty(Domain))
            {
                Domain = $"storage.googleapis.com/{Bucket}";
            }

            Metadata metadata = new Metadata
            {
                name = uploadpath,
                acl  = new Acl[]
                {
                    new Acl
                    {
                        entity = "allUsers",
                        role   = "READER"
                    }
                }
            };

            string metadatajson = JsonConvert.SerializeObject(metadata);

            UploadResult result = SendRequestFile($"https://www.googleapis.com/upload/storage/v1/b/{Bucket}/o?uploadType=multipart", stream, fileName,
                                                  headers: googleAuth.GetAuthHeaders(), contentType: "multipart/related", metadata: metadatajson);
            GoogleCloudStorageResponse upload = JsonConvert.DeserializeObject <GoogleCloudStorageResponse>(result.Response);

            if (upload.name != uploadpath)
            {
                Errors.Add("Upload failed.");
                return(null);
            }

            result.URL = URLHelpers.FixPrefix($"{Domain}/{uploadpath}", "https://");

            return(result);
        }
예제 #19
0
파일: Seafile.cs 프로젝트: thushan/ShareX
        public string ShareFile(string path)
        {
            string url = URLHelpers.FixPrefix(APIURL);

            url = URLHelpers.CombineURL(url, "repos", RepoID, "file/shared-link/");

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("p", path);
            args.Add("share_type", "download");
            if (!string.IsNullOrEmpty(SharePassword))
            {
                args.Add("password", SharePassword);
            }
            if (ShareDaysToExpire > 0)
            {
                args.Add("expire", ShareDaysToExpire.ToString());
            }

            NameValueCollection headers = new NameValueCollection();

            headers.Add("Authorization", "Token " + AuthToken);

            SSLBypassHelper sslBypassHelper = null;

            try
            {
                if (IgnoreInvalidCert)
                {
                    sslBypassHelper = new SSLBypassHelper();
                }

                SendRequestURLEncoded(HttpMethod.PUT, url, args, headers);
                return(LastResponseInfo.Headers["Location"]);
            }
            finally
            {
                if (sslBypassHelper != null)
                {
                    sslBypassHelper.Dispose();
                }
            }
        }
예제 #20
0
        public override UploadResult ShortenURL(string url)
        {
            UploadResult result = new UploadResult {
                URL = url
            };

            Host = URLHelpers.FixPrefix(Host);

            Dictionary <string, string> args = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(Key))
            {
                if (UseAPIv1)
                {
                    args.Add("apikey", Key);
                }
                else
                {
                    args.Add("key", Key);
                }
            }

            if (UseAPIv1)
            {
                args.Add("action", "shorten");
            }

            args.Add("url", url);

            if (IsSecret && !UseAPIv1)
            {
                args.Add("is_secret", "true");
            }

            string response = SendRequest(HttpMethod.GET, Host, args);

            if (!string.IsNullOrEmpty(response))
            {
                result.ShortenedURL = response;
            }

            return(result);
        }
예제 #21
0
        public string Submit(string url)
        {
            if (string.IsNullOrEmpty(Settings.Host))
            {
                Settings.Host = "https://kutt.it";
            }
            else
            {
                Settings.Host = URLHelpers.FixPrefix(Settings.Host);
            }

            string requestURL = URLHelpers.CombineURL(Settings.Host, "/api/v2/links");

            KuttShortenLinkBody body = new KuttShortenLinkBody()
            {
                target    = url,
                password  = Settings.Password,
                customurl = null,
                reuse     = Settings.Reuse,
                domain    = Settings.Domain
            };

            string json = JsonConvert.SerializeObject(body);

            NameValueCollection headers = new NameValueCollection();

            headers.Add("X-API-KEY", Settings.APIKey);

            string response = SendRequest(HttpMethod.POST, requestURL, json, RequestHelpers.ContentTypeJSON, headers: headers);

            if (!string.IsNullOrEmpty(response))
            {
                KuttShortenLinkResponse shortenLinkResponse = JsonConvert.DeserializeObject <KuttShortenLinkResponse>(response);

                if (shortenLinkResponse != null)
                {
                    return(shortenLinkResponse.link);
                }
            }

            return(null);
        }
예제 #22
0
        public string GenerateURL(string uploadPath, bool isRequest = false)
        {
            string url;

            if (!isRequest && !string.IsNullOrEmpty(AzureStorageCustomDomain))
            {
                url = URLHelpers.CombineURL(AzureStorageCustomDomain, uploadPath);
                url = URLHelpers.FixPrefix(url, "https://");
            }
            else if (!isRequest && AzureStorageContainer == "$root")
            {
                url = $"https://{AzureStorageAccountName}.{AzureStorageEnvironment}/{uploadPath}";
            }
            else
            {
                url = $"https://{AzureStorageAccountName}.{AzureStorageEnvironment}/{AzureStorageContainer}/{uploadPath}";
            }

            return(url);
        }
예제 #23
0
        public string GenerateURL(string uploadPath)
        {
            if (!string.IsNullOrEmpty(Settings.Endpoint) && !string.IsNullOrEmpty(Settings.Bucket))
            {
                string url;

                if (Settings.UseCustomCNAME && !string.IsNullOrEmpty(Settings.CustomDomain))
                {
                    url = URLHelpers.CombineURL(Settings.CustomDomain, uploadPath);
                }
                else
                {
                    url = URLHelpers.CombineURL(Settings.Endpoint, Settings.Bucket, uploadPath);
                }

                return(URLHelpers.FixPrefix(url, "https://"));
            }

            return("");
        }
예제 #24
0
파일: AmazonS3.cs 프로젝트: Gigabait/ShareX
        public string GenerateURL(string fileName)
        {
            if (!string.IsNullOrEmpty(Settings.RegionHostname) && !string.IsNullOrEmpty(Settings.Bucket))
            {
                string uploadPath = GetUploadPath(fileName);

                string url;

                if (Settings.UseCustomCNAME && !string.IsNullOrEmpty(Settings.CustomDomain))
                {
                    url = URLHelpers.CombineURL(Settings.CustomDomain, uploadPath);
                }
                else
                {
                    url = URLHelpers.CombineURL(Settings.RegionHostname, Settings.Bucket, uploadPath);
                }

                return(URLHelpers.FixPrefix(url, "https://"));
            }

            return("");
        }
예제 #25
0
        public bool CheckAuthToken()
        {
            string url = URLHelpers.FixPrefix(APIURL);

            url = URLHelpers.CombineURL(APIURL, "auth/ping/?format=json");

            NameValueCollection headers = new NameValueCollection();

            headers.Add("Authorization", "Token " + AuthToken);

            SSLBypassHelper sslBypassHelper = null;

            try
            {
                if (IgnoreInvalidCert)
                {
                    sslBypassHelper = new SSLBypassHelper();
                }

                string response = SendRequest(HttpMethod.GET, url, null, headers);

                if (!string.IsNullOrEmpty(response))
                {
                    if (response == "\"pong\"")
                    {
                        return(true);
                    }
                }

                return(false);
            }
            finally
            {
                if (sslBypassHelper != null)
                {
                    sslBypassHelper.Dispose();
                }
            }
        }
예제 #26
0
파일: Seafile.cs 프로젝트: ywscr/ShareX
        public string GetAuthToken(string username, string password)
        {
            string url = URLHelpers.FixPrefix(APIURL);
            url = URLHelpers.CombineURL(url, "auth-token/?format=json");

            Dictionary<string, string> args = new Dictionary<string, string>
            {
                { "username", username },
                { "password", password }
            };

            string response = SendRequestMultiPart(url, args);

            if (!string.IsNullOrEmpty(response))
            {
                SeafileAuthResponse AuthResult = JsonConvert.DeserializeObject<SeafileAuthResponse>(response);

                return AuthResult.token;
            }

            return "";
        }
예제 #27
0
        public List <SeafileLibraryObj> GetLibraries()
        {
            string url = URLHelpers.FixPrefix(APIURL);

            url = URLHelpers.CombineURL(APIURL, "repos/?format=json");

            NameValueCollection headers = new NameValueCollection();

            headers.Add("Authorization", "Token " + AuthToken);

            SSLBypassHelper sslBypassHelper = null;

            try
            {
                if (IgnoreInvalidCert)
                {
                    sslBypassHelper = new SSLBypassHelper();
                }

                string response = SendRequest(HttpMethod.GET, url, null, headers);

                if (!string.IsNullOrEmpty(response))
                {
                    List <SeafileLibraryObj> JsonResponse = JsonConvert.DeserializeObject <List <SeafileLibraryObj> >(response);

                    return(JsonResponse);
                }

                return(null);
            }
            finally
            {
                if (sslBypassHelper != null)
                {
                    sslBypassHelper.Dispose();
                }
            }
        }
예제 #28
0
        public string GetOrMakeDefaultLibrary(string authtoken = null)
        {
            string url = URLHelpers.FixPrefix(APIURL);

            url = URLHelpers.CombineURL(APIURL, "default-repo/?format=json");

            NameValueCollection headers = new NameValueCollection();

            headers.Add("Authorization", "Token " + (authtoken == null ? AuthToken : authtoken));

            SSLBypassHelper sslBypassHelper = null;

            try
            {
                if (IgnoreInvalidCert)
                {
                    sslBypassHelper = new SSLBypassHelper();
                }

                string response = SendRequest(HttpMethod.GET, url, null, headers);

                if (!string.IsNullOrEmpty(response))
                {
                    SeafileDefaultLibraryObj JsonResponse = JsonConvert.DeserializeObject <SeafileDefaultLibraryObj>(response);

                    return(JsonResponse.repo_id);
                }

                return(null);
            }
            finally
            {
                if (sslBypassHelper != null)
                {
                    sslBypassHelper.Dispose();
                }
            }
        }
예제 #29
0
        public SeafileCheckAccInfoResponse GetAccountInfo()
        {
            string url = URLHelpers.FixPrefix(APIURL);

            url = URLHelpers.CombineURL(APIURL, "account/info/?format=json");

            NameValueCollection headers = new NameValueCollection();

            headers.Add("Authorization", "Token " + AuthToken);

            SSLBypassHelper sslBypassHelper = null;

            try
            {
                if (IgnoreInvalidCert)
                {
                    sslBypassHelper = new SSLBypassHelper();
                }

                string response = SendRequest(HttpMethod.GET, url, null, headers);

                if (!string.IsNullOrEmpty(response))
                {
                    SeafileCheckAccInfoResponse AccInfoResponse = JsonConvert.DeserializeObject <SeafileCheckAccInfoResponse>(response);

                    return(AccInfoResponse);
                }

                return(null);
            }
            finally
            {
                if (sslBypassHelper != null)
                {
                    sslBypassHelper.Dispose();
                }
            }
        }
예제 #30
0
        public string GenerateURL(string uploadPath)
        {
            if (!string.IsNullOrEmpty(Settings.Endpoint) && !string.IsNullOrEmpty(Settings.Bucket))
            {
                uploadPath = URLHelpers.URLPathEncode(uploadPath);

                string url;

                if (Settings.UseCustomCNAME && !string.IsNullOrEmpty(Settings.CustomDomain))
                {
                    string parsedDomain = new CustomUploaderItem().ParseURL(Settings.CustomDomain, false);
                    url = URLHelpers.CombineURL(parsedDomain, uploadPath);
                }
                else
                {
                    url = URLHelpers.CombineURL(Settings.Endpoint, Settings.Bucket, uploadPath);
                }

                return(URLHelpers.FixPrefix(url, "https://"));
            }

            return("");
        }