Helpers/Utils: Automatically change URL to sync.elwig.at when applicable
This commit is contained in:
@ -434,8 +434,7 @@ namespace Elwig.Helpers {
|
||||
if (accept != null)
|
||||
client.DefaultRequestHeaders.Accept.Add(new(accept));
|
||||
if (username != null || password != null)
|
||||
client.DefaultRequestHeaders.Authorization = new("Basic", Convert.ToBase64String(
|
||||
Utils.UTF8.GetBytes($"{username}:{password}")));
|
||||
client.DefaultRequestHeaders.Authorization = new("Basic", Convert.ToBase64String(Utils.UTF8.GetBytes($"{username}:{password}")));
|
||||
return client;
|
||||
}
|
||||
|
||||
@ -454,6 +453,8 @@ namespace Elwig.Helpers {
|
||||
}
|
||||
|
||||
public static async Task UploadExportData(string zip, string url, string username, string password) {
|
||||
if (url.StartsWith("https://elwig.at/clients/"))
|
||||
url = "https://sync.elwig.at/" + url[25..];
|
||||
if (!url.EndsWith('/')) url += "/";
|
||||
using var client = GetHttpClient(username, password, accept: "application/json");
|
||||
var content = new StreamContent(new FileStream(zip, FileMode.Open, FileAccess.Read));
|
||||
@ -463,6 +464,8 @@ namespace Elwig.Helpers {
|
||||
}
|
||||
|
||||
public static async Task<JsonArray> GetExportMetaData(string url, string username, string password) {
|
||||
if (url.StartsWith("https://elwig.at/clients/"))
|
||||
url = "https://sync.elwig.at/" + url[25..];
|
||||
using var client = GetHttpClient(username, password, accept: "application/json");
|
||||
using var res = await client.GetAsync(url);
|
||||
res.EnsureSuccessStatusCode();
|
||||
|
Reference in New Issue
Block a user