When is a file a file?

So, you are writing a web application, and you have several areas of the site where the user can upload files. My main working method for this is to store the actual file on the server and have a database table that associates the saved file name with the record to which it refers.

My question is this: should there be another table for each file type? Also, should the files be stored in context-sensitive places on the server or all together?

Some examples: user profile photos, resumes with the application, related documents on CMS pages, etc.

+5
source share
4 answers

, , .

  • CV, .
  • CMS.

( cv), → → cms_pages. , HABTM, .

toIt.

, - "" , .

mimetype , HTTP.

+3

, , (UUID - ) . "" -, . , (, CV ..) ..

, FS , .

+2

.

-, .

-, - (, , ), (, CV), .

-, , , , .

, (), .

, , .

+2

A different table for each file type becomes relevant if you save other metadata (and, therefore, additional columns) for each file type. If your tables for each file type contain only the same columns (for example, file name, file type, date, etc.), then it would be advisable that they all be on the same table.

+2
source

All Articles