Download the PHP package burriko/cake-file-storage without Composer

On this page you can find all versions of the php package burriko/cake-file-storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cake-file-storage

CakePHP File Storage Behavior Build Status

A file storage plugin for CakePHP 2.x. For the CakePHP 1.x behavior see the cakephp1 branch.

Handles attaching files to models and storing uploaded files in database or filesystem. If uploading to filesystem will store metadata in database.

Files saved in the filesystem will be saved in a directory hierarchy based on the hash of the file contents. Filenames are not used, so will never clash. The hierarchy is to ease performance issues when storing a very large number of files.

Installation

If you're using composer then just add the following to your require block.

    "burriko/cake-file-storage": "2.1.*@dev"

If you're not, then clone/copy the contents of this directory to app/Plugins/CakeFileStorage.

Configure

  1. Add the following line to your app/Config/bootstrap.php.

    CakePlugin::load('CakeFileStorage');
  2. In your model add:

    public $actsAs = array('CakeFileStorage.FileStorage');
  3. Your model's database schema will need fields for filename, type and size. If storing the file in the filesystem you will also need one named hash, and if storing in db one named content. Here is an example schema.

    CREATE TABLE `files` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `filename` varchar(100) NOT NULL,
      `type` varchar(100) NOT NULL,
      `size` mediumint(8) unsigned NOT NULL,
      `content` mediumblob NOT NULL,
      `hash` varchar(40) NOT NULL,
      `created` datetime NOT NULL,
      `modified` datetime NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Usage

When saving this model, if there is a form field named 'file' it will be saved as a file using the behavior. By default it will be saved to the filesystem in an 'uploads' folder in the root folder of your app. The defaults can be changed by passing settings to the behavior as follows.

    public $actsAs = array(
        'CakeFileStorage.FileStorage' => array(
            'storage_type' => 'filesystem',
            'file_path' => '/path/to/files'
            'field_name' => 'my_file'
        )
    );

The behaviour also provides a validation message to check that the file uploaded without any problems. This can be used as follows.

    public $validate = array(
        'file' => array(
            'rule' => 'checkFileUpload',
            'message' => 'There was a problem uploading your file.'
        )
    );

You can retrieve the file from the model by using the fetchFile() method, and send the file back as a response by using the downloadFile() method of the FileStorage component. Here's an example controller that puts those together.

    class DocumentsController extends AppController
    {
        public $components = array('CakeFileStorage.FileStorage');

        public function download($id)
        {
            $document = $this->Document->fetchFile($id);

            return $this->FileStorage->createFileResponse($document);
        }
    }

When deleting a record the file will also be removed from disk, but only if no other record is pointing to the same file (because files are saved under a hash of their contents, if the same file was uploaded for multiple records they would all share the same file on disk).


All versions of cake-file-storage with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
composer/installers Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package burriko/cake-file-storage contains the following files

Loading the files please wait ...