I am creating an image server to process and distribute company images. My goal is to create a system that can receive images (from FTP or app), resize / watermark them, and make them available for social media or internal use (with good small URL).
The problem involves limiting access to it. Each image is allocated an 8 digit code. The Htaccess file is designed to return the correct image so that:
mysite.com/84375635 mysite.com/images/84375635.png
This allows any image I want to set up a system that will restrict specific images based on the requirements stored in the database or file. I'v thought of possible solutions:
- Use php to rewrite the htaccess file when an image is uploaded.
- Use php to obtain image requests, according to the restriction restrictions in the redirect database.
Which is a better option (or do I still not know?)
I want this element of the system to be quick and low-memory as possible for.
Definitely use PHP to process image requests, and query that script into database .
Do not rewrite the .htaccess
files with a PHP per request. Probably this will not work too, php rules will be parsed after the execution, not after this.
If the database server is running on the local host, then this script will cause the overhead to be negligible, time and memory consumption.
If the restrictions are based solely on those IP categories that are allowed to access files, and those that are not, you can rewrite access rules on image uploads.
Note that this also depends on the number of images you upload: If this is a case, then this is not a problem - but in a .htaccess
file hundred thousand There are rules that should not do something (a PHP-based image service script, which is not only fast with the database but also secure).
Although this solution requires little resources, it is also less expandable (such as when you want to add more restrictions than IPS only one day). When you delete the images, keep in mind to remove the entries as well.
Comments
Post a Comment