我现在已经知道可以利用官方api的绑定事件的方法获得大文件的上传进度,但是对于小文件怎么办呢?
public String ResumablePutFile(string upToken, string key, string fname)
{
Console.WriteLine("\n===> ResumablePutFile {0} fname:{1}", key, fname);
Console.WriteLine(upToken);
Settings setting = new Settings();
ResumablePutExtra extra = new ResumablePutExtra();
extra.Notify += this.showNotify;
extra.NotifyErr += this.showNotifyErr;
this.notifyIcon1.ShowBalloonTip(30, "注意", fname + " 正在上传", ToolTipIcon.Info);
ResumablePut client = new ResumablePut(setting, extra);
CallRet ret = client.PutFile(upToken, fname, key);
if (ret.OK)
{
Console.WriteLine("success");
string result = ret.Response;
Console.WriteLine(result);
JObject jo = JObject.Parse(result);
string[] valuesH = jo.Properties().Select(item => item.Value.ToString()).ToArray();
string hash = valuesH[0];
return hash;
}
else
{
Console.WriteLine("fail");
return "";
}
}
我想你可以参考一下这个创建块的api接口:http://developer.qiniu.com/docs/v6/api/reference/up/mkblk.html
块大小可以是通过参数firstChunkSize来自定义的