Binary files such as images are not normally stored inside a regular database. Instead they need to be stored in a 3rd party file storage service such as Amazon S3 or Dropbox. Agile Toolkit supports multiple 3rd party storages:
Agile Toolkit contains several UI widgets that allow you to operate with files: upload, work with images, categorize or associate files with other data. Those widgets can work with any 3rd party storage system which implements a proper storage controller.
The most basic way to use storage controller is to associate it with Model_File model:
$f = $this->add('Model_File'); $f->setStorage('S3'); $f->upload($my_file_path);
The above code will upload the file located at $my_file_path and store it as object inside Amazon S3. The other information about the file such as filename, type, size and check-sum will be stored in your regular database called my-files.
Once uploaded, the Model_File will represent your actual file inside Agile Toolkit, you can search for files directly by name, type or through associations.
There are 3 parts at play when you operate with the files.
The #3 is optional and use of existing 3rd party class would greatly simplify implementation of Controller_Storage.
Describes a physical file and it’s properties.
The model is defining the following fields:
To access meta properties use:
or to perform search by a meta-property:
$file->addCondition('meta.size', '>', 1000000);
Sub-model conditions are only supported for Databases that are capable of storing and indexing hierarchic data, e.g. Clusterpoint, Mongo.
Import and store specified file.
Will download file from public URL and verify md5.
Retrive file, store locally in a temproary location and return full path.
Controller for abstraction of 3rd party file storage systems. If you need to store files with another file storage service, you might need to create your own controller. The following methods will have to be implemented.
Store specified file and update $model fields (location, storage, url)
Load model corresponding to a specified model and return filename.
Delete file object corresponding to the model.