Posts

Showing posts with the label download

Download File from S3 Bucket API Using AWS .Net SDK

Image
  In one of my previous posts  Upload File to S3 Bucket API Using AWS .Net SDK  I explain how to upload a file to an S3 bucket and get the file path where your file was stored. Assuming that you have persisted this file path somewhere somehow, I will show you in this post how to download the file using the file path. Using the same set-up in my previous post linked above let's start with adding an interface method that performs the needed service. File Data When the S3 SDK gets you the object that exists in the file path and bucket name provided, it's in the form of a stream. You should have a content type so that you are able to tell the receiver of your API what type of file they are getting. Luckily, we can get this information from the Content-Type header from the response, but we need a model that can hold this piece of information. So, let's create a class named FileData which can hold the stream and the content type of the file received from S3. namespace Domain....

Download Image API Using MediatR Vertical Architecture

Image
As I mentioned in one of my previous posts, I will be showing you how to make an API that downloads an image to a local path.  But I will take this as an opportunity to show you an example of how to achieve that using vertical architecture with MediatR . One of the most common problems with clean architecture is that there usually is a service class for each domain entity that encapsulates all application logic regarding this entity.  Something that if you have applied on a larger scale project with a little too much business logic you would find that the class got too big, and maintainability becomes a little more difficult by each added logic.  Also, data transfer objects ( DTO ) start to have weirder names because you can't have a one-size-fits-all model that accommodate the growing logic in your service class.  (eg. CustomerDTO.cs, LoyalCustomerDTO.cs, CustomerLightWeightDTO.cs) Not to mention of course pull requests and merging codes become a living nightmare....