-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDriveApi.cs
64 lines (55 loc) · 1.83 KB
/
DriveApi.cs
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
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace CLARiNET
{
internal class DriveApi
{
public static string BuildSoapRequest(string file, string contents, string uploadedBy, bool trashed)
{
string xmlData = "";
string delimiter = "~";
string[] data = null;
string username = "";
string filename = "";
string wid = "";
if (file.Contains(","))
{
delimiter = ",";
}
data = file.Split(delimiter);
if (data.Length > 1)
{
username = Path.GetFileName(data[0]);
filename = data[1];
if (data.Length > 2)
{
wid = data[2];
}
if (trashed)
{
xmlData = ResourceFile.Read("Put_Drive_Document_Content_Request_Trashed.xml");
}
else
{
xmlData = ResourceFile.Read("Put_Drive_Document_Content_Request.xml");
}
string contentType = WDContentType.Lookup(filename);
xmlData = xmlData.Replace("{contents}", contents)
.Replace("{document_wid}", wid)
.Replace("{filename}", filename.EscapeXml())
.Replace("{owned_by_username}", username.EscapeXml())
.Replace("{uploaded_by_username}", username.EscapeXml())
.Replace("{contentType}", contentType);
}
else
{
throw new Exception("Could not parse file name or read input line.");
}
return xmlData;
}
}
}