And leave datas for runtime-generated files only
Trustmaster |
|
---|---|
Currently we have (basicly) 3 executable PHP files in datas folder: config.php, extensions.php and mimetype.php. The rest of datas contents is user files, uploads and temporary files. There is a proposal in the community to put configuration files into a separate root folder named 'cfg'. The reasoning behind such a measure is:
The downside is backwards compatibility. Despite path to config.php is hardcoded, it is quite easy to replace massively. But the files should be moved to a new folder manually on existing sites because install.php isn't likely to have enough permissions. Post here what you think and some alternative solutions. May the Source be with you!
|
GHengeveld |
|
---|---|
Considering Kilandor's arguments here and the relation of this topic to the PFS and file-handling in Cotonti in general, I suggest the following:
The reason to allow custom file storage handling is clear: default file handling isn't suitable for all sites. Currently the PFS supports storing all files in 1 folder, which is a very crude option, and it supports 'Folder Storage Mode' which gives each user its own folder and stores their uploads there. Both of these options are relatively simple and won't really scale well (talking 1000+ files here, or 10000+ for FSM). And then there is the issue of naming files. Some prefer to have filenames with a timestamp, some want the user ID in there, others just want to retain the original filename (which is tricky since users are likely to upload files with identical names). I think we should allow the admin to choose which storage handling he prefers. This also means we will need a way to move files around to allow changing storage mode afterwards. My solution to file storage is like this:
This system has several benefits:
Downsides are:
|
|
Отредактировано: GHengeveld (02.12.2011 22:14, 13 лет назад) |
esclkm |
|
---|---|
I think Cfg folder is good variant littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты |
Trustmaster |
|
---|---|
Gert, that sounds way too difficult even for me, not to mention the others :) May the Source be with you!
|
GHengeveld |
|
---|---|
Okay, but I still think a generic API for file storage is a welcome addition. Actually, I've been working on the storage method I described for a while and it isn't that complicated, except for the exponential part (which is optional). |
Twiebie |
|
---|---|
May I add that I think it's best if filenames will keep their original filename? Ofcourse something can/should be added to the filename to make it unique, but I think it's better for users if they can actually see the name of a file they are downloading. Something like cf766fdc72.rar doesn't really say much to the average person that's looking for a file. In the method you described, it will put the original filename in the database, so it could be displayed in PFS. But that would still leave the problem of random generated filenames that in my opinion are just not as nice as actual filenames (linking to a file etc...). |
GHengeveld |
|
---|---|
PHP will change back the file name before returning the file to the user, so the user will never see the random file name, even when he downloads it. This can be done using header content disposition attachment filename (Google it).
|
esclkm |
|
---|---|
GHengeveld - I miss understand about renaming files - i think its very bad tone littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты |
GHengeveld |
|
---|---|
Ok, nevermind my argument towars a generic file API. I'll just continue to work on a seperate module which incorporates these features. I'm fine with a cfg subfolder, even though I think the root is getting a bit too crowded (I think routing most of the stuff through index.php will solve that). |
Kilandor |
|
---|---|
Well I think a file api would be fine and a good idea as a basis. I think some of the things described are a bit overkill and will not matter to a majority of users. I would also go so far as to take the base of the idea so that the API would do its folder structure based upon the module/plugin. So say I have a plugin for image uploads and then another for Videos. It would be like datas/raw/images or datas/raw/video . This will allow for quick cleanup say on removal. I started to think the api should not have a database and the module/plugin should handle it but I changed my mind. The api should have a database. It should also include identifiable to mod/plug and user as well. So the files can still be identifiable on the backend but need not be for the actual file such as is now 1-Foo.png I do not think that we need expoential folders and limit to the number of files in these. It would require tracking or something else. Just for example Mediawiki simply uses the first 2 characters from the MD5 of the file name. It does not expoentially have folders Of course we can use PHP hashing system to hash the uploaded file completly. Relative to size of the file and what not this could very easily fail on servers/hosts depending on the size of the file. So I think hashing off the file name is the only logical choice. This would still let you know the path/name though. So likely appending the timestamp to the filename simply for the purpose of generating the hash would be appropriate. I think this should be a seperate issue for the file handling, I think simply for the task at and and per the topic that the cfg should be moved. This way things like extension/mimetype can have our cotonti system defaults, which can be overridden by or added to by custom configs in the cfg folder. |