//后台代码
public static class Qiniu_API
{
public static string Bucket = "";//空间名
public static string Domain = "";//域名
static Qiniu_API()
{
Config.ACCESS_KEY = "<AK>"; //AK
Config.SECRET_KEY = "<SK>";//SK
}
public static void ResumablePutFile(string bucket, string key, string fname)
{
Console.WriteLine("\n===> ResumablePutFile {0}:{1} fname:{2}", bucket, key, fname);
PutPolicy policy = new PutPolicy(bucket, 3600);
string upToken = policy.Token();
Settings setting = new Settings();
ResumablePutExtra extra = new ResumablePutExtra();
ResumablePut client = new ResumablePut(setting, extra);
client.PutFile(upToken,fname, key);
}
}
protected void confirm_Click(object sender, EventArgs e)
{
HttpFileCollection collection = HttpContext.Current.Request.Files;
HttpPostedFile file = collection[0];
string bucket = "maitian";
Qiniu_API.ResumablePutFile(bucket, null, file.value);
}
点击后显示:
检查下文件路径,另外中文文件名编码是否正确