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