Skip to content

Commit

Permalink
update env acquire
Browse files Browse the repository at this point in the history
  • Loading branch information
Naserien committed Apr 24, 2024
1 parent 5e43131 commit eeb4660
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
17 changes: 13 additions & 4 deletions C_Sharp/WEB/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@page "/"
@inject IConfiguration Configuration
@inject HttpClient httpClient

<PageTitle>Photo Upload</PageTitle>

Expand Down Expand Up @@ -27,7 +29,13 @@
private List<IBrowserFile> uploadedFiles = new List<IBrowserFile>();
private string uploadStatus = "";
private string statusClass = "";
@inject HttpClient httpClient;
private string apiUrl;

Check warning on line 32 in C_Sharp/WEB/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'apiUrl' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 32 in C_Sharp/WEB/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'apiUrl' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

protected override void OnInitialized()
{
apiUrl = Configuration["photo_process_url"];

Check warning on line 36 in C_Sharp/WEB/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build

Possible null reference assignment.

Check warning on line 36 in C_Sharp/WEB/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build

Possible null reference assignment.
base.OnInitialized();
}

private void OnInputFileChange(InputFileChangeEventArgs e)
{
Expand All @@ -48,9 +56,8 @@

try
{
var functionUrl = Environment.GetEnvironmentVariable("photo_process_url");
var response = await httpClient.PostAsync(functionUrl, content);

var response = await httpClient.PostAsync(apiUrl, content);

if (response.IsSuccessStatusCode)
{
// Handle the success scenario
Expand All @@ -76,6 +83,8 @@
await stream.DisposeAsync();
}
}

uploadedFiles.Clear(); // Clear the list after all files are processed
}
}

Expand Down
11 changes: 11 additions & 0 deletions C_Sharp/WEB/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// ...other codess...
}

0 comments on commit eeb4660

Please sign in to comment.