Filesystem.Module Documentation

How filesystem.module and fileapi.inc fit into the drupal architecture:
[inline:filesystemAPIstack.png]
*this image does not include repositories*

core filesystem concepts

  • storage drivers
  • repositories
  • fileapi
  • filesystem

Walk though from the bottom up....

storage drivers implement callbacks for various file storage systems. They provide basic file functions for whatever storage system they support. The provide a settings form and validate callback as well as their file handling callbacks.

repositories are an instance of a storage driver. A repository has a mountpoint, a driver, a driver's settings, access control callbacks, and a system flags which determines whether the repository can be deleted or not.

fileapi abstracts the repositories and storages drivers from developers and provides stable UI for developers that works with file paths. Its is a lower level api to replace functions like php's copy/move/unlink.

filesystem provides and upper level api, treating files as arrays with a multitude metadata. It does concurrent database operations with fileapi operations. It provides custom file elements, a generic filebrowser interface, and utility tools for other modules to make developing file centric sites easier.

and now in a drupal far far away. my errata

Filesystem.module expects files to be an array.

Example of file object.


$file = array(
'fid' => '', //unique file id
'uid' => '', //uid file is associated to
'name' => 'filename.ext', //display name of file
'path' => 'files/filename', //absolute path && real filename
'mime' => 'text/plain', //mime type of file
'size' => 33032, //filesize
'attributes => array( //associative array of file metadata.
'key' =>'value'
),
);

fileapi expects a path. fileapi_invoke_storage_driver handles parsing out the storage driver used for a particular mount point.

filesystem.module associates files to uids instead of nids. This makes the file life cycle asynchronous to the node life cycle.

fileapi.inc provides low-level file functions with support for storage drivers.

filesystem.module provides a richer api which combines low-level file handling and db handling in single function calls. It also provides a basic filebrowser, and an intelligent form element for handling uploads.

**these need to be revised to match the current code im working with**
APIS:

filesystem.module:

filesystem_manage((array)$file)
filesystem_unmanage((array)$file)
filesystem_privatize((array)$file, $access_control_callback)
filesystem_publicize((array)$file)
filesystem_copy((array)$file, (array)$file)
filesystem_move((array)$file, (array)$file)
filesystem_rm((array)$file)
filesystem_load(array/fid) //node load like syntax
filesystem_get(url)
filesystem_save_metadata((array)$file)
filesystem_get_metadata((array)$file)

fileapi.inc:

bool fileapi_is_file($path)
bool fileapi_is_dir($path)
bool fileapi_exists($path)
errno fileapi_mkdir($path)
errno fileapi_rm($path)
errno fileapi_move($src, $dst)
errno fileapi_copy($src, $dst)
errno fileapi_readdir($src);
errno fileapi_readfile($src);
errno fileapi_get($src);
errno fileapi_upload($src);

storage drivers:

bool storagedriver_$driver_is_file($settings, $path)
bool storagedriver_$driver_is_dir($settings, $path)
bool storagedriver_$driver_mkdir($settings, $path)
bool storagedriver_$driver_rmdir($settings, $path)
bool storagedriver_$driver_rm($settings, $path)
bool storagedriver_$driver_copy($settings, $src, $dst)
bool storagedriver_$driver_move($settings, $src, $dst)
array storagedriver_$driver_readdir($settings, $path)
array storagedriver_$driver_readfile($settings, $path)
bool storagedriver_$driver_exists($settings, $path)
bool storagedriver_$driver_touch($settings, $path)

Comments

What's a uid?

Is the "uid" a user id, or an id which is driver-dependent?

uid as in user id

I mean uid in a traditional drupal sense. User ID.

.darrel.

Some trouble....

Hi,

This module is very interesting.
I'd like to install it on Drupal 4.7.3 but I've got a bug notification (see this bug report : http://drupal.org/node/80842).

Which version of Drupal is used for developement ?

I need a storage driver as

I need a storage driver as of last year. This is cool.

So is this going to be built in a way (i.e., "hook"ed up) so if I want to make Drupal aware of other file types, I can do that? The obvious stuff like hooks that can handle images or audio files in special ways on upload, so Drupal can "know" more about them (e.g., store extra metadata like "width" and "height") or process them a la the image module...