///
/// 上传文件
///
/// 上传Token
/// key
/// 本地文件名
public CallRet PutFile(string upToken, string localFile, string key)
{
if (!File.Exists(localFile))
{
throw new Exception(string.Format("{0} does not exist", localFile));
}
PutAuthClient client = new PutAuthClient(upToken);
CallRet ret;
using (FileStream fs = File.OpenRead(localFile))
{
int block_cnt = block_count(fs.Length);
long fsize = fs.Length;
extra.Progresses = new BlkputRet[block_cnt];
byte[] byteBuf = new byte[BLOCKSIZE];
int readLen = BLOCKSIZE;
for (int i = 0; i < block_cnt; i++)
{
if (i == block_cnt - 1) {
readLen = (int)(fsize - (long)i * BLOCKSIZE);
}
fs.Seek((long)i * BLOCKSIZE, SeekOrigin.Begin);
fs.Read(byteBuf, 0, readLen);
BlkputRet blkRet = ResumableBlockPut(client, byteBuf, i, readLen);
if (blkRet == null)
{
extra.OnNotifyErr(new PutNotifyErrorEvent(i, readLen, "Make Block Error"));
}
else
{
extra.OnNotify(new PutNotifyEvent(i, readLen, extra.Progresses[i]));
}
}
ret = Mkfile(client, key, fsize);
}
if (ret.OK)
{
if (PutFinished != null)
{
PutFinished(this, ret);
}
}
else
{
if (PutFailure != null)
{
PutFailure(this, ret);
}
}
return ret;
}
参数localfile应该是文件的绝对路径,如果用input:file 上传,后台怎么获取上传文件的绝对路径赋给这个参数啊?