dmyers/laravel-storage

This package is abandoned and no longer maintained. No replacement package was suggested.

A simple storage filesystem package for Laravel 4.

v1.0.10 2016-03-14 06:27 UTC

This package is auto-updated.

Last update: 2022-11-10 10:37:10 UTC


README

Storage is a filesystem abstraction layer for Laravel 4 applications. If you are using Laravel 5 it comes with a similar package included which can be found in the docs.

Installation via Composer

Add this to you composer.json file, in the require object:

"dmyers/laravel-storage": "1.*"

After that, run composer install to install Storage.

Add the service provider to app/config/app.php, within the providers array.

'providers' => array(
    // ...
    'Dmyers\Storage\StorageServiceProvider',
)

Add a class alias to app/config/app.php, within the aliases array.

'aliases' => array(
    // ...
    'Storage' => 'Dmyers\Storage\Storage',
)

Finally, ensure the files directory defined in the config file is created and writable by the web server (defaults to public/files).

$ mkdir public/files
$ chmod -R 777 public/files

Configuration

Publish the default config file to your application so you can make modifications.

$ php artisan config:publish dmyers/laravel-storage

Usage

Check if a file exists in storage:

Storage::exists('user/avatar.jpg');

Get a file's contents from storage:

Storage::get('user/avatar.jpg');

Put a file into storage:

Storage::put('user/avatar.jpg', $contents);

Upload a file into storage:

Storage::upload(Input::file('avatar'), 'user/avatar.jpg');

Upload a remote file into storage:

Storage::remoteUpload('http://laravel.com/favicon.ico', 'user/avatar.jpg');

Download a file from storage:

Storage::download('user/avatar.jpg', 'tmp/images/user-1/avatar.jpg');

Download a remote file locally:

Storage::remoteDownload('http://laravel.com/favicon.ico', 'tmp/images/user-1/avatar.jpg');

Delete a file from storage:

Storage::delete('user/avatar.jpg');

Move a file in storage:

Storage::move('user/avatar.jpg', 'user/1/avatar.jpg');

Copy a file in storage:

Storage::copy('user/avatar.jpg', 'user/avatar.bak.jpg');

Get a file's type from storage:

Storage::type('user/avatar.jpg');

Get a file's mime type from storage:

Storage::mime('user/avatar.jpg');

Get a file's size from storage:

Storage::size('user/avatar.jpg');

Get a file's last modification date from storage:

Storage::lastModified('user/avatar.jpg');

Check if a path is a directory in storage:

Storage::isDirectory('user/avatar.jpg');

List all files in storage:

Storage::files('images');

Get the full URL to a file in storage:

Storage::url('user/avatar.jpg');

Render a file from storage to the browser:

Storage::render('user/avatar.jpg');