'Download a file through a docker web container
I have this web app which classifies images into certain tags with .NET Machine Learning. It's a blazor web app which is run through a docker container and everything works as it should. However, once the classification is done, I want to move that image to a server's directory and save it there. But for some reason docker won't let me make this redirection; while I AM able to do it inside Visual Studio's debugger. So for this reason, I'm guessing it has something to do with my dockerfile. This is my dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 7040
ENV ASPNETCORE_URLS=http://+:7040
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["machineLearningAPI.csproj", "./"]
RUN dotnet restore "machineLearningAPI.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "machineLearningAPI.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "machineLearningAPI.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "machineLearningAPI.dll"]
And this is the function which does the redirecting:
public async Task saveToDir(string dir)
{
using var stream = photoStream.OpenReadStream(512000);
using(var uploadimg = new FileStream(dir, FileMode.Create))
{
await stream.CopyToAsync(uploadimg);
}
stream.Close();
testPath = dir;
File.Delete(imagePath);
}
And this is the only error I get from inside the Blazor App, nothing prompts up from Visual Studio: Blazor Error
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
