4using System.Threading.Tasks;
21 : base(
"/UpdateBackupFolderSettings")
59 !(Content.
Decoded is Dictionary<string, object> Form) ||
60 !Form.TryGetValue(
"ExportFolder", out
object Obj) || !(Obj is
string ExportFolder) ||
61 !Form.TryGetValue(
"KeyFolder", out Obj) || !(Obj is
string KeyFolder) ||
62 !Form.TryGetValue(
"BackupHosts", out Obj) || !(Obj is
string BackupHostsStr) ||
63 !Form.TryGetValue(
"KeyHosts", out Obj) || !(Obj is
string KeyHostsStr))
70 ExportFolder = ExportFolder.Trim();
71 KeyFolder = KeyFolder.Trim();
73 string[] BackupHosts = BackupHostsStr.Split(
',');
74 string[] KeyHosts = KeyHostsStr.Split(
',');
80 Len = ExportFolder.Length;
81 if (Len > 0 && (ExportFolder[Len - 1] ==
'/' || ExportFolder[Len - 1] ==
'\\'))
82 ExportFolder = ExportFolder[..(Len - 1)];
84 Len = KeyFolder.Length;
85 if (Len > 0 && (KeyFolder[Len - 1] ==
'/' || KeyFolder[Len - 1] ==
'\\'))
86 KeyFolder = KeyFolder[..(Len - 1)];
88 if (!
string.IsNullOrEmpty(ExportFolder))
90 if (!Path.IsPathRooted(ExportFolder))
92 Response.StatusCode = 400;
93 Response.StatusMessage =
"Bad Request";
95 await Response.
Write(
"Export folder must be rooted. Relative paths are not accepted.");
100 if (!Directory.Exists(ExportFolder))
102 Response.StatusCode = 400;
103 Response.StatusMessage =
"Bad Request";
105 await Response.
Write(
"Export folder does not exist, or cannot be accessed or reached.");
112 string s = ExportFolder + Path.DirectorySeparatorChar +
"test.txt";
118 Response.StatusCode = 400;
119 Response.StatusMessage =
"Bad Request";
121 await Response.
Write(
"Not allowed to write data to the export folder.");
127 if (!
string.IsNullOrEmpty(KeyFolder))
129 if (!Path.IsPathRooted(KeyFolder))
131 Response.StatusCode = 400;
132 Response.StatusMessage =
"Bad Request";
134 await Response.
Write(
"Key folder must be rooted. Relative paths are not accepted.");
139 if (!Directory.Exists(KeyFolder))
141 Response.StatusCode = 400;
142 Response.StatusMessage =
"Bad Request";
144 await Response.
Write(
"Key folder does not exist, or cannot be accessed or reached.");
151 string s = KeyFolder + Path.DirectorySeparatorChar +
"test.txt";
157 Response.StatusCode = 400;
158 Response.StatusMessage =
"Bad Request";
160 await Response.
Write(
"Not allowed to write data to the key folder.");
171 Response.StatusCode = 200;
172 Response.StatusMessage =
"OK";
176 private static void Trim(
string[] Array)
178 int i, c = Array.Length;
180 for (i = 0; i < c; i++)
181 Array[i] = Array[i].Trim();
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
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< ContentResponse > 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...
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...
static Task WriteAllTextAsync(string FileName, string Text)
Creates a text file asynchronously.
POST Interface for HTTP resources.