|
static void | WriteFiles (Stream requestStream, IEnumerable< UploadFile > files, string boundary) |
|
static void | WriteValues (Stream requestStream, NameValueCollection values, string boundary) |
|
Definition at line 11 of file UploadFile.cs.
◆ UploadFile()
Terraria.ModLoader.IO.UploadFile.UploadFile |
( |
| ) |
|
◆ GetUploadFilesRequestData()
static byte [] Terraria.ModLoader.IO.UploadFile.GetUploadFilesRequestData |
( |
IEnumerable< UploadFile > |
files, |
|
|
NameValueCollection |
values |
|
) |
| |
|
static |
Definition at line 45 of file UploadFile.cs.
46 var boundary =
"---------------------------" + DateTime.Now.Ticks.ToString(
"x", NumberFormatInfo.InvariantInfo);
47 boundary =
"--" + boundary;
48 using (var requestStream =
new MemoryStream()) {
51 var boundaryBuffer = Encoding.ASCII.GetBytes(boundary +
"--");
52 requestStream.Write(boundaryBuffer, 0, boundaryBuffer.Length);
53 return requestStream.ToArray();
static void WriteFiles(Stream requestStream, IEnumerable< UploadFile > files, string boundary)
static void WriteValues(Stream requestStream, NameValueCollection values, string boundary)
◆ UploadFiles()
static byte [] Terraria.ModLoader.IO.UploadFile.UploadFiles |
( |
string |
address, |
|
|
IEnumerable< UploadFile > |
files, |
|
|
NameValueCollection |
values |
|
) |
| |
|
static |
Definition at line 25 of file UploadFile.cs.
26 var request = WebRequest.Create(address);
27 request.Method =
"POST";
28 var boundary =
"---------------------------" + DateTime.Now.Ticks.ToString(
"x", NumberFormatInfo.InvariantInfo);
29 request.ContentType =
"multipart/form-data; boundary=" + boundary;
30 boundary =
"--" + boundary;
31 using (var requestStream = request.GetRequestStream()) {
34 var boundaryBuffer = Encoding.ASCII.GetBytes(boundary +
"--");
35 requestStream.Write(boundaryBuffer, 0, boundaryBuffer.Length);
37 using (var response = request.GetResponse())
38 using (var responseStream = response.GetResponseStream())
39 using (var stream =
new MemoryStream()) {
40 responseStream.CopyTo(stream);
41 return stream.ToArray();
static void WriteFiles(Stream requestStream, IEnumerable< UploadFile > files, string boundary)
static void WriteValues(Stream requestStream, NameValueCollection values, string boundary)
◆ WriteFiles()
static void Terraria.ModLoader.IO.UploadFile.WriteFiles |
( |
Stream |
requestStream, |
|
|
IEnumerable< UploadFile > |
files, |
|
|
string |
boundary |
|
) |
| |
|
staticprivate |
Definition at line 72 of file UploadFile.cs.
References Terraria.ModLoader.Environment.
77 foreach (var file
in files) {
78 var buffer = Encoding.ASCII.GetBytes(boundary +
Environment.NewLine);
79 requestStream.Write(buffer, 0, buffer.Length);
80 buffer = Encoding.UTF8.GetBytes(
string.Format(
"Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"{2}", file.Name, file.Filename,
Environment.NewLine));
81 requestStream.Write(buffer, 0, buffer.Length);
82 buffer = Encoding.ASCII.GetBytes(
string.Format(
"Content-Type: {0}{1}{1}", file.ContentType,
Environment.NewLine));
83 requestStream.Write(buffer, 0, buffer.Length);
84 requestStream.Write(file.Content, 0, file.Content.Length);
85 buffer = Encoding.ASCII.GetBytes(
Environment.NewLine);
86 requestStream.Write(buffer, 0, buffer.Length);
Sandstorm, Hell, Above surface during Eclipse, Space
◆ WriteValues()
static void Terraria.ModLoader.IO.UploadFile.WriteValues |
( |
Stream |
requestStream, |
|
|
NameValueCollection |
values, |
|
|
string |
boundary |
|
) |
| |
|
staticprivate |
Definition at line 57 of file UploadFile.cs.
References Terraria.ModLoader.Environment.
62 foreach (
string name
in values.Keys) {
63 var buffer = Encoding.ASCII.GetBytes(boundary +
Environment.NewLine);
64 requestStream.Write(buffer, 0, buffer.Length);
65 buffer = Encoding.ASCII.GetBytes(
string.Format(
"Content-Disposition: form-data; name=\"{0}\"{1}{1}", name,
Environment.NewLine));
66 requestStream.Write(buffer, 0, buffer.Length);
67 buffer = Encoding.UTF8.GetBytes(values[name] +
Environment.NewLine);
68 requestStream.Write(buffer, 0, buffer.Length);
Sandstorm, Hell, Above surface during Eclipse, Space
◆ Content
byte [] Terraria.ModLoader.IO.UploadFile.Content |
|
getset |
◆ ContentType
string Terraria.ModLoader.IO.UploadFile.ContentType |
|
getset |
◆ Filename
string Terraria.ModLoader.IO.UploadFile.Filename |
|
getset |
◆ Name
string Terraria.ModLoader.IO.UploadFile.Name |
|
getset |