2using System.Collections.Generic;
4using System.Threading.Tasks;
20 : base(
"/UpdateBackupFolderSettings")
54 if (!(Obj is Dictionary<string, object> Form) ||
55 !Form.TryGetValue(
"ExportFolder", out Obj) || !(Obj is
string ExportFolder) ||
56 !Form.TryGetValue(
"KeyFolder", out Obj) || !(Obj is
string KeyFolder) ||
57 !Form.TryGetValue(
"BackupHosts", out Obj) || !(Obj is
string BackupHostsStr) ||
58 !Form.TryGetValue(
"KeyHosts", out Obj) || !(Obj is
string KeyHostsStr))
64 ExportFolder = ExportFolder.Trim();
65 KeyFolder = KeyFolder.Trim();
67 string[] BackupHosts = BackupHostsStr.Split(
',');
68 string[] KeyHosts = KeyHostsStr.Split(
',');
74 Len = ExportFolder.Length;
75 if (Len > 0 && (ExportFolder[Len - 1] ==
'/' || ExportFolder[Len - 1] ==
'\\'))
76 ExportFolder = ExportFolder.Substring(0, Len - 1);
78 Len = KeyFolder.Length;
79 if (Len > 0 && (KeyFolder[Len - 1] ==
'/' || KeyFolder[Len - 1] ==
'\\'))
80 KeyFolder = KeyFolder.Substring(0, Len - 1);
82 if (!
string.IsNullOrEmpty(ExportFolder))
84 if (!Path.IsPathRooted(ExportFolder))
86 Response.StatusCode = 400;
87 Response.StatusMessage =
"Bad Request";
89 await Response.
Write(
"Export folder must be rooted. Relative paths are not accepted.");
94 if (!Directory.Exists(ExportFolder))
96 Response.StatusCode = 400;
97 Response.StatusMessage =
"Bad Request";
99 await Response.
Write(
"Export folder does not exist, or cannot be accessed or reached.");
106 string s = ExportFolder + Path.DirectorySeparatorChar +
"test.txt";
112 Response.StatusCode = 400;
113 Response.StatusMessage =
"Bad Request";
115 await Response.
Write(
"Not allowed to write data to the export folder.");
121 if (!
string.IsNullOrEmpty(KeyFolder))
123 if (!Path.IsPathRooted(KeyFolder))
125 Response.StatusCode = 400;
126 Response.StatusMessage =
"Bad Request";
128 await Response.
Write(
"Key folder must be rooted. Relative paths are not accepted.");
133 if (!Directory.Exists(KeyFolder))
135 Response.StatusCode = 400;
136 Response.StatusMessage =
"Bad Request";
138 await Response.
Write(
"Key folder does not exist, or cannot be accessed or reached.");
145 string s = KeyFolder + Path.DirectorySeparatorChar +
"test.txt";
151 Response.StatusCode = 400;
152 Response.StatusMessage =
"Bad Request";
154 await Response.
Write(
"Not allowed to write data to the key folder.");
165 Response.StatusCode = 200;
166 Response.StatusMessage =
"OK";
170 private static void Trim(
string[] Array)
172 int i, c = Array.Length;
174 for (i = 0; i < c; i++)
175 Array[i] = Array[i].Trim();
Static class managing loading of resources stored as embedded resources or in content files.
static Task WriteAllTextAsync(string FileName, string Text)
Creates a text file asynchronously.
Plain text encoder/decoder.
const string DefaultContentType
text/plain
Static class managing data export.
static async Task SetKeyHostsAsync(string[] Value)
Secondary key hosts.
static async Task SetBackupHostsAsync(string[] Value)
Secondary backup hosts.
static async Task SetExportFolderAsync(string Value)
Export folder.
static async Task SetExportKeyFolderAsync(string Value)
Key folder
Static class managing the runtime environment of the IoT Gateway.
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
Web Resource for updating where backup files are storeed.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
bool AllowsPOST
If the POST method is allowed.
override bool HandlesSubPaths
If the resource handles sub-paths.
override bool UserSessions
If the resource uses user sessions.
UpdateBackupFolderSettings()
Web Resource for updating where backup files are storeed.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
bool HasData
If the request has data.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
async Task Write(byte[] Data)
Returns binary data in the response.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
POST Interface for HTTP resources.