File Storage

Hi,

just because it’s not part of Yii and hasn’t been discussed yet. Are there plans for a kind of file storage component in Yii 2.0?

If a component, module or extension has to deal with files it may be useful if there would be a framework component helping them.

Basically this would be similar to a cache module, you may set or get files from the file storage component, but it may implement additional boundaries, if a module wants to store its files protected, so another module can’t access it.

Also the file storage could come with a convention where to store the files (e.g. protected/data, protected/var).

Best regards,

schmunk

How’s this different from regular PHP file management functionality?

A "CFileStorage" would encapsulate the methods needed for file handling and could implement additional features like the boundaries I mentioned.

For sure you could still access files directly with PHP methods, but that’s also true for other framework components, such as messages or authItems.

Additionally you could replace the component to implement another file storage (e.g. in a database, CDN).

At least I would like to see a convention like the /assets folder where the web application should store persistent files. My proposal would be protected/data or protected/var.

PS: Same could be asked for CHttpSession or the Cache components :)

So this is basically a backend for key-value storage. Persistent one.

Yes basically, if you treat the path of the file as the key, but it may provide additional features like,

  • better error handling

  • automatic creation of subdirectories

  • improved organization on file / folder basis, like .git/objects

  • delete to trash, empty trash

  • getting files by attributes (like find)

…just thinking loud.