Download the PHP package cjci/res_storage without Composer
On this page you can find all versions of the php package cjci/res_storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cjci/res_storage
More information about cjci/res_storage
Files in cjci/res_storage
Package res_storage
Short Description CodeIgniter Resource management library. Store files using Encryption and handle file metadata.
License GPL3
Informations about the package res_storage
CI_Resource_Management
Resource Management Class for Codeigniter framework. It allows to store and process files w/wo encryption
What is CI Resource Management
This is a library coded to work in CodeIgniter Framework that helps in the process of management resources - files - and storing them in your filesystem with or without encryption. By default it uses rijndael-256 - commonly known as AES256 - to store files.
If your web application handles a lot of files, that you must secure in some way and want to have a common library to do all the hard work of storing and encrypting files in your application. This library is for you.
Installation
1.a (If you use composer) Execute: composer require cjci/res_storage
and fill in
your desired version (dev-master for latest changes).
1.b (Manually) Download desired version of this project to application/libraries/
- Create your own res_storage.php config file in application/config to configure your path and encryption key. (see Usage for more details)
Usage
Codeigniters wrapper to loader class
This class can be used in anywhere in your code just by its FQNS CJCI/ResStorage/ResStorage
But, if you want to use $this->load->('res_storage')
in your code, because you are familiar
with CI Loader. Just create a res_storage.php file in your application/libraries folder.
Contents as follows:
Now we need to configure where to store files and a new clear secretkey. (It will be the basis of a new hashed secret key)
Creating a res_storage.php file in your CodeIgniter's config dir:
$config['clearkey'] = "YourSecretKey" ;
$config['storage_dir'] = "/Path/To/Your/Filesystem/";
Or as a parameter when using CI Loader Class:
$this->load->library('res_storage',array('clearkey' => 'MyKey','storage_dir' => '/Path'));
Instantiate
$this->load->library('res_storage');
Store a file
When storing files it will store a copy of that file.
It wont move or delete original file.
$uuid = $this->res_storage->store_file('/Path/to/File.txt');
$uuid is auniq a string identifier that identifies that file in the future.
Storing a file will store a copy of a document. using a file handler class (Encrypted AES256 32IV by default) And also will store metadata of that document into res_storage table.
Read Metadata
var_dump($this->res_storage->metadata($uuid));
Returns
Get File contents
$contents = $this->res_storage->file_get_contents($uuid);
Output contents to browser using metadata
Uses metadata to write some headers and then file contents
$this->res_storage->readfile($uuid);
Delete File
$this->res_storage->delete($uuid)
Everything will throw an Exception if something goes wrong. So if you want to be safe and not have halfloaded pages... try using try-catch:
Creating your own FileHandle with your own encryption
Extend and include somewhere in your code RSFile Class if you don't want to use MCRYPT to store your files encrypted. Otherwise extend RSFileEncrypted and modify it's properties to fit your needs.
Add to your config/res_storage.php:
$config['file_handler'] = 'My_File_Handler' ;
Or Extend ResStorage and override the following to use your FileHandler:
License
GPL V3