jezzsantos / saastack

A comprehensive codebase template for starting your real-world, fully featured SaaS web products. On the .NET platform
The Unlicense
15 stars 5 forks source link

Download images by file extension #33

Closed jezzsantos closed 2 months ago

jezzsantos commented 2 months ago

Presently, you can upload an image and its content-type is limited to GIF, JPEG, PNG, and that is calculated by the signature of the first few bytes. We store the raw image and the content-type of the image and we use URLs like this (https://host.com/images/image_1234567890123456789012/download) to download the image.

Now, when downloading an image, you are expected to include an Accept header, and this is limited to either:

  1. image/png
  2. image/gif
  3. image/jpeg
  4. or no Accept header

Anything else is rejected. The problem is that the caller that wants to download the image needs to know the content-type to include in the download request.

The actual content type is NOT knowledge they would readily have.

Solution

Instead of providing the Accept header, it would be better to just make the download request without any Accept header or use the value of */* for the Accept header. To do this, we would be better to either: