#region Copyright (C) 2016 Kevin (OSS开源系列) 公众号:osscoder
/***************************************************************************
* 文件功能描述:Http请求 == 文件参数
*
* 创建人: Kevin
* 创建人Email:1985088337@qq.com
*
*****************************************************************************/
#endregion
using System;
using System.IO;
namespace OSS.Http.Models
{
public struct FileParameter
{
///
/// 构造函数
///
/// 参数的名称
/// 调用方会自动释放
///
///
public FileParameter(string name, Stream fileStream, string filename, string contentType)
{
this.Writer = s =>
{
var buffer = new byte[1024];
var byteCount=0;
using (fileStream)
{
int readCount = 0;
while ((readCount= fileStream.Read(buffer, 0, buffer.Length))!=0)
{
s.Write(buffer,0,readCount);
byteCount += readCount;
}
}
return byteCount;
};
this.FileName = filename;
this.ContentType = contentType;
this.Name = name;
}
///
/// 参数名称
///
public string Name;
///
/// 读写操作流
/// 返回的是写入的字节流长度
///
public Func Writer;
///
/// 文件名称
///
public string FileName;
///
/// 文件类型
///
public string ContentType;
}
}