Abstract layer for working with file system

8 years ago

arron
Member | 462
+
0
-

I would be cool to have some abstract layer for file system. Then it would be possible to easily implement the AWS S3 storage for example.

It there any plan for this? Or did anyone work on something like that?

Thank you a lot.

8 years ago

na1k
Member | 289
+
0
-

Is this what you are looking for?

Or you can implement custom file protocol (mystorage://) and use it with the Finder

8 years ago

arron
Member | 462
+
0
-

I am really sorry, I was out of my mind when I was asking this question:-) Nette has its abstract layer, for example cache is using it.

But I found, that sessions is using native php functions. So what to do, when I want to save sessions somewhere else? There is some ISessionStorage, but it seems to not be used at all.

na1k wrote:

Is this what you are looking for?

Or you can implement custom file protocol (mystorage://) and use it with the Finder

That looks interesting, thank you.

Last edited by arron (2011-08-29 20:24)

8 years ago

Jan Tvrdík
Nette guru | 2563
+
0
-

arron wrote:

So what to do, when I want to save sessions somewhere else? There is some ISessionStorage, but it seems to not be used at all.

Just configure sessions to use your session storage via Nette\Http\Session::setStorage().

8 years ago

arron
Member | 462
+
0
-

This was the point, where looking into source-code was unsuccessfull, because I wasn't looking deep enaugh. Thank you!

8 years ago

vkrishn
Member | 9
+
0
-

Is there implementation for simple file operations, like:

  1. Check if file/folder present.
  2. Create dir with desired permissions.
  3. Unlink
  4. Process fileperms() or stats(), symlinks.
  5. Guess file mime-type.
  6. Simple read/write operations.

Can this be part of util/finder?
Storages\FileStorage could use this common methods.

8 years ago

HosipLan
Moderator | 4693
+
0
-

Why there would be such a tool? PHP can do this on it's own. Nette always was, and will be lightweight.

8 years ago

vkrishn
Member | 9
+
0
-

Some of the classes do have these methods, to some extend, implemented internally.
Moving them to a common class perhaps Files.php under Nette\Utils or Nette\Caching\Storages can be done.

Overall the above methods can be implemented in less than 10kb file size. Not calculating the removal of some codes from some files in Storages and Config.

Building a product based application often requires an installation phase and module update routines. Having them inbuilt in a framework would be great.

8 years ago

David Grudl
Nette Core | 6877
+
0
-

For simple file operations there is native class SplFileObject. (API is terrible, but better than nothing).

8 years ago

vkrishn
Member | 9
+
0
-

The closest would be,

  1. http://pear.php.net/package/File/ (20%) – more if required, part of which is in Storages/FileStorage
  2. http://pear.php.net/…e/File_Find/ (60%) – part of which I guess is already in Utils/Finder
  3. http://pear.php.net/…e/File_Util/ (80%)
  4. A simple file type guessing based on extension.

Reason:
To build/deploy a product based on nette framework would require such routines.
Having them build in framework with nette style error handling.

Though implementing the above would be nice, I am in favour of a lightweight framework. :-)

Last edited by vkrishn (2012-03-22 05:52)