mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:56:31 +00:00
add resource folder to config for proper folder auto upload
This commit is contained in:
@@ -5,4 +5,5 @@ public class ApiConfig
|
||||
public string Url { get; set; } = null!;
|
||||
public int RetryCount {get;set;}
|
||||
public double TimeoutSeconds { get; set; }
|
||||
public string ResourcesFolder { get; set; } = "";
|
||||
}
|
||||
|
||||
@@ -12,26 +12,26 @@ public class AzaionApiClient(HttpClient httpClient) : IDisposable
|
||||
{
|
||||
const string JSON_MEDIA = "application/json";
|
||||
|
||||
private static ApiConfig _apiConfig = null!;
|
||||
|
||||
private string Email { get; set; } = null!;
|
||||
private SecureString Password { get; set; } = new();
|
||||
|
||||
private string JwtToken { get; set; } = null!;
|
||||
public User User { get; set; } = null!;
|
||||
|
||||
public static AzaionApiClient Create(ApiCredentials credentials)
|
||||
{
|
||||
ApiConfig apiConfig;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(SecurityConstants.CONFIG_PATH))
|
||||
throw new FileNotFoundException(SecurityConstants.CONFIG_PATH);
|
||||
var configStr = File.ReadAllText(SecurityConstants.CONFIG_PATH);
|
||||
apiConfig = JsonConvert.DeserializeObject<SecureAppConfig>(configStr)!.ApiConfig;
|
||||
_apiConfig = JsonConvert.DeserializeObject<SecureAppConfig>(configStr)!.ApiConfig;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
apiConfig = new ApiConfig
|
||||
_apiConfig = new ApiConfig
|
||||
{
|
||||
Url = SecurityConstants.DEFAULT_API_URL,
|
||||
RetryCount = SecurityConstants.DEFAULT_API_RETRY_COUNT ,
|
||||
@@ -41,8 +41,8 @@ public class AzaionApiClient(HttpClient httpClient) : IDisposable
|
||||
|
||||
var api = new AzaionApiClient(new HttpClient
|
||||
{
|
||||
BaseAddress = new Uri(apiConfig.Url),
|
||||
Timeout = TimeSpan.FromSeconds(apiConfig.TimeoutSeconds)
|
||||
BaseAddress = new Uri(_apiConfig.Url),
|
||||
Timeout = TimeSpan.FromSeconds(_apiConfig.TimeoutSeconds)
|
||||
});
|
||||
|
||||
api.EnterCredentials(credentials);
|
||||
@@ -60,7 +60,7 @@ public class AzaionApiClient(HttpClient httpClient) : IDisposable
|
||||
|
||||
public async Task<Stream> GetResource(string fileName, string password, HardwareInfo hardware)
|
||||
{
|
||||
var response = await Send(httpClient, new HttpRequestMessage(HttpMethod.Post, "/resources/get")
|
||||
var response = await Send(httpClient, new HttpRequestMessage(HttpMethod.Post, $"/resources/get/{_apiConfig.ResourcesFolder}")
|
||||
{
|
||||
Content = new StringContent(JsonConvert.SerializeObject(new { fileName, password, hardware }), Encoding.UTF8, JSON_MEDIA)
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"Url": "https://api.azaion.com/",
|
||||
"RetryCount": 3,
|
||||
"TimeoutSeconds": 40.0,
|
||||
"ResourcesFolder": "stage",
|
||||
"TokenFile": "token.txt"
|
||||
},
|
||||
"DirectoriesConfig": {
|
||||
|
||||
@@ -3,6 +3,7 @@ set CONFIG=%1
|
||||
@echo off
|
||||
|
||||
set API_URL=https://api.azaion.com
|
||||
set RESOURCES_FOLDER=stage
|
||||
|
||||
set EMAIL=uploader@azaion.com
|
||||
set PASSWORD=Az@1on_10Upl0@der
|
||||
@@ -28,12 +29,12 @@ for /f "tokens=2 delims=:" %%a in ('echo %RESPONSE% ^| findstr /i "token"') do (
|
||||
|
||||
echo Uploading files to resources...
|
||||
|
||||
curl --location %API_URL%/resources ^
|
||||
curl --location %API_URL%/resources/%RESOURCES_FOLDER% ^
|
||||
-H "Authorization: Bearer %TOKEN%" ^
|
||||
-H "Content-Type: multipart/form-data" ^
|
||||
--form "data=@%FILE1_TO_UPLOAD%"
|
||||
|
||||
curl --location %API_URL%/resources ^
|
||||
curl --location %API_URL%/resources/%RESOURCES_FOLDER% ^
|
||||
-H "Authorization: Bearer %TOKEN%" ^
|
||||
-H "Content-Type: multipart/form-data" ^
|
||||
--form "data=@%FILE2_TO_UPLOAD%"
|
||||
|
||||
Reference in New Issue
Block a user