electronic heartbreak.
Docker-compose volume storing image
In my Web API I receive images. These images should be stored, prefferable in my local directory. My project uses docker (compose).
I managed to use a volume where the images are getting stored in a folder called
unfiltered_images
in the docker container.
However, the saved images do not appear into my specified folder on my d-drive.
docker-compose
In the future. I want to deploy this app onto my Raspberry Pi where an external hard disk will be used to store the images.7 replies
Is it possible to create a file outside the project folder?
A yes/no question basically.
This is the code I currently use to create and store files.
When the
StoragePath
is "uploads", it creates an upload
directory within my project folder
.
9 replies
Architectural advice needed
Hi, as the title suggest I am looking for advice on my current architecture and how I can improve things. I have some knowlegde on both onion architecture and clean architecture.
My current solution is setup like this:
In brief, my API takes in an Image, validates it and then the image should be stored into a folder. Now for the storage I rely on my
Service
. Would it not be better to place my API in my Service project?
If you have other suggestions or improvements feel free to suggest them.5 replies
Unable to properly launch Web API using Docker (Compose)
As the title suggests, I am having issues in running my Web API through Docker. When I launch the project and want to open it using localhost it is unreachable.
My project structure:
Solution/
- docker-compose (default)
- docker-compose.override (default)
- API/
- dockerfile
The files:
Dockerfile:
Docker-compose:
7 replies
Azurite to run in VS or Docker
As the title suggests I wonder if there are any tradeoffs whether I should use Azurite through the built-in Visual Studio method or to implement it through Docker?
The project is already configured in Docker, so maybe that's a hint it should be used through Docker too?
1 replies
Using IFormFile in Web API project results in network failure.
Hello everyone reading this thread,
As the title suggests, I am trying to upload an image using the
IFormFile
interface in a property. When I upload the image, the system 'crashes' and I get a network failure with the following message:
This is the only code I have added to a default ASP .NET Web API project:
Controller:
6 replies
How is Modelstate.IsValid triggered?
Hello!
I am reading this tutorial on how DTO's can be implemented with API's: https://dev.to/moe23/net-6-automapper-data-transfer-objects-dtos-49e
The process in this tutorial seems normal and you can easily follow along.
There are only 2 things I have my questions about:
1. The Driver class in this tutorial has no DataAnnotations (see first codeblock). How come the Modelstate.IsValid can be triggered in codeblock 2?
2. How does Modelstate.IsValid get triggered when a Dto is passed but it gets mapped to an entity?
91 replies
ASP.NET Core Web API byte[] issues
Hello there,
I am trying to accept a byte array in my API request:
Swagger is used to test the API. When I launch the project and open it in my browser I see that this property accepts a string instead of a byte[]. Googling this issue did not gave much information besides this SO-thread
https://stackoverflow.com/questions/77233543/call-an-api-with-byte-array-in-net-6
My question is if this is good enough or has anyone else faced similar issues?
15 replies
✅ Expandability of the ASP.NET WEB API - Mongo tutorial code
Hello there,
I am currently following this tutorial: https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-8.0&tabs=visual-studio
This tutorial explores the integration of mongo and c#. What in this tutorial is done is that they set collection, database and connection in the
env
-like file. This means that when you have multiple collections you need to add them here and expend all the setting classes.
Another issue I see with this is that https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-8.0&tabs=visual-studio#add-a-crud-operations-service is not maintainable in the long run, becuase of this line:
Would an EF-like approach be more suitable? So you have a MongoDBContext class that holds the collections and DI this Context class into the Service classes?152 replies
Testing private methods
Hey there, I have the following code:
I want to unit test this code using NUnit, When creating a Setup and initializing the class these 2 methods are in, and trying to write a test for the
IsInputValid
I see that I cant test private methods. However, it feels needed to test that method. I worked around the issue doing the following, but this feel very ugly.
If you have a solution for this or adivce, I am curious to know!7 replies