Skip to content

Instantly share code, notes, and snippets.

@travcunn
Last active August 29, 2015 14:14
Show Gist options
  • Save travcunn/0db59f2a8bc831bf61b0 to your computer and use it in GitHub Desktop.
Save travcunn/0db59f2a8bc831bf61b0 to your computer and use it in GitHub Desktop.
SmartFile file upload
using System;
using System.IO;
using System.Web;
using System.Net;
using System.Collections;
using SmartFile;
namespace SmartFileTest
{
class MainClass
{
public static int Main (string[] args)
{
// Setup new SmartFile client
BasicClient api = new BasicClient();
// Data to send in POST request
Hashtable p = new Hashtable();
p.Add("file0", new FileInfo("wallpaper.jpg"));
// Upload file to /windowstest/wallpaper.jpg
HttpWebResponse r = api.Post("path/data/windowstest", null, p);
// Display JSON result of SmartFile API call in the console
StreamReader _Answer = new StreamReader(r.GetResponseStream());
Console.WriteLine(_Answer.ReadToEnd());
return 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment