Files
2023-05-23 10:47:19 +08:00

65 lines
1.9 KiB
C#
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#region Copyright (C) 2016 Kevin (OSS开源系列) 公众号:osscore
/***************************************************************************
*   文件功能描述:Http请求 == 文件参数
*
*   创建人: Kevin
* 创建人Email:1985088337@qq.com
*
*****************************************************************************/
#endregion
namespace OSS.Tools.Http
{
/// <summary>
/// 文件参数
/// </summary>
public struct FileParameter
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="name">参数的名称</param>
/// <param name="fileStream">调用方会自动释放</param>
/// <param name="filename"></param>
/// <param name="contentType"></param>
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;
}
/// <summary>
/// 参数名称
/// </summary>
public string Name;
/// <summary>
/// 读写操作流
/// 返回的是写入的字节流长度
/// </summary>
internal Action<Stream> Writer;
/// <summary>
/// 文件名称
/// </summary>
public string FileName;
/// <summary>
/// 文件类型
/// </summary>
public string ContentType;
}
}