Directory structure for file host

I have a simple file host that gives the files a unique identifier and just saves them in a directory. I was told that this will cause problems in the future, and I wonder what I should look for to make sure that it works smoothly in the future and beyond.

Also, is there a performance issue when forcing downloads by sending header information and readfile ()? Would it be better to save the file names and allow the use of direct download not to use a script?

thanks

+3
source share
5 answers

, , readfile()?

, . script :

  • ,
  • ETags Last-Modified / .
  • Expires/Cache-Control

- , - (, , C , , ), .

script?

, , - . . .

, URL- :

hxxp://www.example.com/files/1234/Lovely_long_filename_that_can_contain_any_Unicode_character.zip

:

hxxp://www.example.com/realfiles/1234.dat

() -.

+3

, , , .

, , ().

, ID (, 19873) , , <uploads>/73/98/19873_<filename.ext>, 73 - ID % 100, 98 - (ID / 100) % 100 ..

, <uploads> 100 100 <uploads>/*. .

, inodes ( , ), , ext3, ) ( , 20 , ). (10, 1000) 100. 100 100 . 5 .

, , .

+6

. ext3 - .

-, , , ARG_MAX. , rm -rf * . , A-Z/a-z .

, , ... crons like 'updatedb' , . , "".

- . ? 300 , 30 ? , , , /proc/sys/vfs _cache_pressure, Linux PHP/Apache/Etc.

, readfile... . PHP .

+3

, .

, , , , . .

+1
source

I believe that I suggest using a script to control abuse. I also suggest saving file names if your script does not create an index in the database with respect to it in its original state. You can also try to make a script with some Rewrite magic on this, thereby creating another level of security without exposing the real name (your unique identifier) ​​to the end user.

0
source

Source: https://habr.com/ru/post/1704247/


All Articles