forked from NancyFx/Nancy
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathHttpFile.cs
More file actions
61 lines (55 loc) · 2.42 KB
/
HttpFile.cs
File metadata and controls
61 lines (55 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
namespace Nancy
{
using System.IO;
/// <summary>
/// Represents a file that was captured in a HTTP multipart/form-data request
/// </summary>
public class HttpFile
{
/// <summary>
/// Initializes a new instance of the <see cref="HttpFile"/> class,
/// using the provided <paramref name="boundary"/>.
/// </summary>
/// <param name="boundary">The <see cref="HttpMultipartBoundary"/> that contains the file information.</param>
public HttpFile(HttpMultipartBoundary boundary)
: this(boundary.ContentType, boundary.Filename, boundary.Value, boundary.Name)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="HttpFile"/> class,
/// using the provided values
/// </summary>
/// <paramref name="contentType">The content type of the file.</paramref>
/// <paramref name="name">The name of the file.</paramref>
/// <paramref name="value">The content of the file.</paramref>
/// <paramref name="key">The name of the field that uploaded the file.</paramref>
public HttpFile(string contentType, string name, Stream value, string key)
{
this.ContentType = contentType;
this.Name = name;
this.Value = value;
this.Key = key;
}
/// <summary>
/// Gets or sets the type of the content.
/// </summary>
/// <value>A <see cref="string"/> containing the content type of the file.</value>
public string ContentType { get; private set; }
/// <summary>
/// Gets or sets the name of the file.
/// </summary>
/// <value>A <see cref="string"/> containing the name of the file.</value>
public string Name { get; private set; }
/// <summary>
/// Gets or sets the form element name of this file.
/// </summary>
/// <value>A <see cref="string"/> containing the key.</value>
public string Key { get; private set; }
/// <summary>
/// Gets or sets the value stream.
/// </summary>
/// <value>A <see cref="Stream"/> containing the contents of the file.</value>
/// <remarks>This is a <see cref="HttpMultipartSubStream"/> instance that sits ontop of the request stream.</remarks>
public Stream Value { get; private set; }
}
}