c# – Designing an API where an image can be supplied

I am designing an API whereby some other system can supply an image in their POST. As such this is an API for integration purposes, with no front-end. Postman is used for testing the API.

Below is the DTO for the expected POST body written in C#

   public class VideoEventCreateDto

        public double Confidence { get; set; } = 1;
        public DateTime EventTimeStamp { get; set; }
        public string Base64Image { get; set; }
        public string ImageFileName { get; set; }   
        public ImageType ImageFileType { get; set; }

I have two questions:

Question 1

  • According to this article, using Base64 for the image is an old technique that should be avoided: https://tyk.io/api-design-guidance-file-upload/ . However, their alternative solutions seem to relate to having a front-end and only uploading an image by itself. What would be the best solution to change my API to not use Base 64?

Question 2

  • The ImageType is an enum with a list of the supported file extensions. This is useful as it forces the consumer to select from a list of supported file types when the developer reads the API documentation. This will make the API more robust, as it will significantly reduce the likelihood of the consumer supplying an unsupported file type at runtime. However, this information is essentially duplicated in the ImageFileName property by virtue of the fact that it will have a file extension e.g. “myImage.png”. Is this an acceptable design?