Filestore
Filestore is a mechanism of Agile Toolkit to simplify file uploading, storage and association with your database records. Typically the choice on how files are stored by the system is done by a web developer. File data is either stored in the SQL or is kept in a file. In some cases it will be uploaded into the CND (cloud) later.
Agile Toolkit abstracts file uploading by introducing a standard Model for your files and images. This is implemented in a "filestore" add-on.
https://github.com/atk4/atk4-addons/tree/master/filestore
How files are managed?
File uploads in PHP are automatically stored in a temporary folder and then your PHP application needs to put it in a safe location. Filestore does that automatically by putting file inside upload folder. It starts by creating sub-directory '0' and placing files with random names in there. When large number of files is achieved, it will switch to folder '1' and so on until 256 subdirectories are allocated with 4000 files in each. Afterwards new files will be distributed across all the folders. A single volume can store up to 4096*256*256 files (which is a artificial limit). You can have multiple volumes and the filestore will randomly pick enabled volume.
Filenames are generated randomly and are difficult to guess, preventing someone from scanning folder for additional images.
Filestore Introduction
Filestore is an addon which enables developer to implement file upload, storage and manipulation in the unique and consistent way.
Installation Instructions
If Filestore is already implemented and you only need to install it, you should go through a number of steps.
Directory for file storage
Files are being stored in a directory which is associated with the volume. In order to be able to store files you need at least one volume and one writable directory. Create directory first, usually creating "upload" directory inside your webroot is the most convenient way. Secondly find "Filestore admin" page inside your application and add new volume. Make sure you set it as default volume.
Result |
Code
$f=$p->add('MVCForm'); |
Files are being stored in a directory which is associated with the volume. In order to be able to store files you need at least one volume and one writable directory. Create directory first, usually creating "upload" directory inside your webroot is the most convenient way. Secondly find "Filestore admin" page inside your application and add new volume. Make sure you set it as default volume.
Configure file types
Depending on the type of your application, it might require to pre-define all types of uploaded files. If it is necessary to add support for new filetypes, add them into File Types list. Normally adding jpeg, gif and png is most common use.
Result |
Code
$f=$p->add('MVCGrid'); |
Test file upload
File admin has a test upload control. Once you have set up everything, you can try to upload file. It should appear in the list of uploaded files below.
Result |
Code
$f=$p->add('Form'); |
