Suppose in a web application, there is such an entity "file", this entity is divided into two types: "media" and "simple". Delve into the type of "media". The media includes such varieties: images, video and audio. Consider the "images", such a version has a config that includes valid formats, compression ratio, the number and size of the preview, the path to the directory where all files of this type are stored.

This structure has its pros and cons. An obvious advantage is that in order to specify for a specific form field, where the picture should be saved, what format it will have, size, and so on. - it is enough to create your type for it with your config, and the files will go as we need and where we say. Also, if for example files moved to another directory or to another server, then we simply edit the config like this media type, specifying the new address there. Also, if suddenly we needed previews of new sizes, for example, for new pages of the site, then we simply prescribe a new type of preview with its parameters in the config, start the regeneration preview procedure and it will cut us new previews from the originals. The fattest minus of such a structure is that when we want to get a file, we first get the resource id, here we will have a complex query with join, where the resource id needs to get the files and type id, and immediately pull out the type. So we receive in the main request two join'a. This is what I really don't like.

Do you have any idea how to simplify it all without cutting back on flexibility? (I do not consider options with caching yet, because first I want to simplify all this without using a cache).

  • You do not consider cloud-based cluster storage for media files? Swift, Ceph, S3? Are they dimensionless, do they scale well? - cheops
  • No, not yet everything is in line with the issue - sanu0074

0