Exemplo n.º 1
0
        public void ParseResponse(UploadResult result, CustomUploaderInput input, bool isShortenedURL = false)
        {
            if (result != null && !string.IsNullOrEmpty(result.Response))
            {
                CustomUploaderParser parser = new CustomUploaderParser(result.Response, RegexList);
                parser.Filename  = input.Filename;
                parser.URLEncode = true;

                string url;

                if (!string.IsNullOrEmpty(URL))
                {
                    url = parser.Parse(URL);
                }
                else
                {
                    url = parser.Response;
                }

                if (isShortenedURL)
                {
                    result.ShortenedURL = url;
                }
                else
                {
                    result.URL = url;
                }

                result.ThumbnailURL = parser.Parse(ThumbnailURL);
                result.DeletionURL  = parser.Parse(DeletionURL);
            }
        }
Exemplo n.º 2
0
        public string GetData(CustomUploaderInput input)
        {
            CustomUploaderParser parser = new CustomUploaderParser(input);

            parser.UseNameParser = true;
            parser.JSONEncode    = RequestFormat == CustomUploaderRequestFormat.JSON;

            return(parser.Parse(Data));
        }
Exemplo n.º 3
0
        public string GetRequestURL(CustomUploaderInput input)
        {
            if (string.IsNullOrEmpty(RequestURL))
            {
                throw new Exception(Resources.CustomUploaderItem_GetRequestURL_RequestURLMustBeConfigured);
            }

            CustomUploaderParser parser = new CustomUploaderParser(input);

            parser.URLEncode = true;
            string url = parser.Parse(RequestURL);

            return(URLHelpers.FixPrefix(url));
        }
Exemplo n.º 4
0
        public Dictionary <string, string> GetArguments(CustomUploaderInput input)
        {
            Dictionary <string, string> arguments = new Dictionary <string, string>();

            if (Arguments != null)
            {
                CustomUploaderParser parser = new CustomUploaderParser(input);
                parser.UseNameParser = true;

                foreach (KeyValuePair <string, string> arg in Arguments)
                {
                    arguments.Add(arg.Key, parser.Parse(arg.Value));
                }
            }

            return(arguments);
        }
Exemplo n.º 5
0
        public NameValueCollection GetHeaders(CustomUploaderInput input)
        {
            if (Headers != null && Headers.Count > 0)
            {
                NameValueCollection  collection = new NameValueCollection();
                CustomUploaderParser parser     = new CustomUploaderParser(input);
                parser.UseNameParser = true;

                foreach (KeyValuePair <string, string> header in Headers)
                {
                    collection.Add(header.Key, parser.Parse(header.Value));
                }

                return(collection);
            }

            return(null);
        }
Exemplo n.º 6
0
 public CustomUploaderParser(CustomUploaderInput input) : this(input.Filename, input.Input)
 {
 }
Exemplo n.º 7
0
 public CustomUploaderSyntaxParser(CustomUploaderInput input)
 {
     FileName = input.FileName;
     Input    = input.Input;
 }