Ejemplo n.º 1
0
        public static int Main(string[] args)
        {
            /*
             * We expect command line arguments such as:
             * SmartFileTest.exe <method> <endpoint> [ <id> <name>=<value> ]
            */
            if (args.Length < 3)
            {
                Console.WriteLine("You must provide an HTTP method and endpoint.");
                return 1;
            }

            String method = args[0];
            String endpoint = args[1];

            BasicClient api = new BasicClient();

            /* SmartFileTest.exe POST path/data file0= */
            if (method == "POST" && endpoint == "path/data")
            {
                Hashtable p = new Hashtable();
                for (int i = 2; i < args.Length; i++)
                {
                    String argPair = args[i];
                    String[] parts = argPair.Split('=');
                    if (File.Exists(parts[1]))
                        p.Add(parts[0], new FileInfo(parts[1]));
                    else
                        p.Add(parts[0], parts[1]);
                }
                HttpWebResponse r = api.Post("path/data", null, p);
            }

            return 0;
        }
Ejemplo n.º 2
0
        public static int Main(string[] args)
        {
            /*
             * We expect command line arguments such as:
             * SmartFileTest.exe <method> <endpoint> [ <id> <name>=<value> ]
             */

            String method;
            String endpoint;

            if (args.Length < 3)
            {
                Console.WriteLine("You must provide an HTTP method and endpoint.");
                Console.WriteLine("Method:");
                method = Console.ReadLine();
                Console.WriteLine("Endpoint:");
                endpoint = Console.ReadLine();
            }
            else
            {
                method   = args[0];
                endpoint = args[1];
            }



            BasicClient api = new BasicClient();

            if (method == "POST" && endpoint == "path/data")
            {
                Hashtable p = new Hashtable();
                for (int i = 2; i < args.Length; i++)
                {
                    String   argPair = args[i];
                    String[] parts   = argPair.Split('=');
                    if (File.Exists(parts[1]))
                    {
                        p.Add(parts[0], new FileInfo(parts[1]));
                    }
                    else
                    {
                        p.Add(parts[0], parts[1]);
                    }
                }
                HttpWebResponse r = api.Post("path/data", null, p);
            }

            return(0);
        }
    public string clouddownload(string fname)
    {
        string      s;
        BasicClient api = new BasicClient("5FLkdaBJkVG7U1g168EmNneAuHBBjG", "o2I2xXnvWAq5xOeoY9T1sEMrNncyV5");
        Hashtable   p   = new Hashtable();

        p.Add("path", "role_base_access/" + fname);
        p.Add("list", true);
        p.Add("read", true);
        p.Add("name", "Screenshot");
        try
        {
            r = api.Post("/link", null, p);
        }
        catch { }
        using (var streamReader = new StreamReader(r.GetResponseStream()))
        {
            var responseText = streamReader.ReadLine();

            string lab1 = responseText.ToString();



            string furl = lab1.Substring(137, 12).ToString();


            //  HyperLink1.NavigateUrl = "https://file.ac" + furl + "/MyFile/"+forder[0].ToString();
            using (WebClient client = new WebClient())
            {
                s = client.DownloadString("https://file.ac" + furl + "/role_base_access/" + fname);

                //cloudkeypackets.Add(hashvalue);
            }
        }
        return(s);
    }
    public void cloud_upload(string path)
    {
        Environment.SetEnvironmentVariable("SMARTFILE_API_KEY", "5FLkdaBJkVG7U1g168EmNneAuHBBjG");
        Environment.SetEnvironmentVariable("SMARTFILE_API_PASSWORD", "o2I2xXnvWAq5xOeoY9T1sEMrNncyV5");
        Environment.SetEnvironmentVariable("SMARTFILE_API_URL", "https://nandhu.smartfile.com/");



        string          filepath = path;
        BasicClient     api      = new BasicClient();
        FileInfo        FI       = new FileInfo(filepath);//to know the filepath & also the type
        Hashtable       ht       = new Hashtable();
        HttpWebResponse HWR;

        try
        {
            ht.Add("file", FI);

            HWR = api.Post("path/data/role_base_access", null, ht);//path/data/doc is a format given by them
        }
        catch (Exception ex)
        {
        }
    }