UploadFiles() public method

public UploadFiles ( string url, string files ) : ResponseEventArgs
url string
files string
return ResponseEventArgs
Ejemplo n.º 1
0
        public ResponseStatusEventArgs UploadFile(string[] files, string[] tags, string title)
        {
            ResponseStatusEventArgs args = new ResponseStatusEventArgs();
            try
            {
                string parms = "";
                string tags2 = "";
                string title2 = "";
                List<string> parmlist = new List<string>();

                if (tags != null)
                {
                    tags2 = "tags=" + String.Join("%20", tags);
                    parmlist.Add(tags2);
                }
                if (title != null)
                {
                    title2 = "name=" + title;
                    parmlist.Add(title2);
                }
                if (parmlist.Count > 0)
                {
                    parms = "?";
                    var tmp = String.Join("&", parmlist.ToArray());
                    parms += tmp;
                }
                GeoComWebClient request = new GeoComWebClient();
                string url = String.Format("{0}/datasets.json" + parms, EndpointURI);
                setCredentials(request);

                validateFileType(files);
                ResponseEventArgs response = request.UploadFiles(url, files);

                args._result = response.Status;
                try
                {
                    args._location = response.Location;
                }
                catch { }

            }
            catch (Exception ex)
            {
                args._error = ex;
            }
            return args;
        }
Ejemplo n.º 2
0
        public ResponseStatusEventArgs UploadFile(string[] files, string[] tags)
        {
            ResponseStatusEventArgs args = new ResponseStatusEventArgs();
            try
            {
                string parms = "";
                if (tags != null)
                {
                    parms = "?tags=" + String.Join("%20", tags);
                }
                GeoComWebClient request = new GeoComWebClient();
                string url = String.Format("{0}/datasets.json" + parms, EndpointURI);
                setCredentials(request);

                validateFileType(files);
                ResponseEventArgs response = request.UploadFiles(url, files);

                args._result = response.Status;
                try
                {
                    args._location = response.Location;
                }
                catch { }

            }
            catch (Exception ex)
            {
                args._error = ex;
            }
            return args;
        }