\apex\app\iostorage

Remote File Storage Handler

Service: apex\svc\storage

Handles the management of file storage via the remote/flysystem package, allowing for files to be distributed amongst multiple servers / services such as AWS.

This class is available within the services container, meaning its methods can be accessed statically via the service singleton as shown below.

PHP Example

<?php

namespace apex;

use apex\app; use apex\svc\storage;

( ( // Set cache item cache::set('some_id', 'my item contents');

// Get cache item $data = cache::get('some_id');

Summary

Methods
Properties
Constants
__construct()
add()
add_contents()
has()
get()
get_stream()
delete()
rename()
copy()
create_dir()
delete_dir()
get_mime_type()
get_timestamp()
get_size()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$fs
$adapter_type
N/A

Properties

$fs

$fs : 

Type

$adapter_type

$adapter_type : 

Type

Methods

__construct()

__construct(string  $adapter_type = '', array  $credentials = array()) 

Constructor. Create the adapter.

Parameters

string $adapter_type

The type of adapter to use. If blank, uses the default config var 'core:flysystem_type'.

array $credentials

add()

add(string  $dest, string  $filename, string  $visibility = 'public', boolean  $can_overwrite = true) : boolean

Add file

Checks the filesize, and if greater than 1MB will stream it, otherwise will do a straight write file method.

Parameters

string $dest

The path of the file destination

string $filename

The full path of the local file to add.

string $visibility

Mode of the file, either 'public' or 'private'.

boolean $can_overwrite

Whether or not the file can be overwritten if already exists. Defaults to true.

Returns

boolean —

Whther or not the operation was successful.

add_contents()

add_contents(string  $dest, string  $contents, string  $visibility = 'public', boolean  $can_overwrite = true) : boolean

Add file from contents

Parameters

string $dest

The path of the file destination

string $contents

The contents of the file to add

string $visibility

Mode of the file, either 'public' or 'private'.

boolean $can_overwrite

Whether or not the file can be overwritten if already exists. Defaults to true.

Returns

boolean —

Whther or not the operation was successful.

has()

has(string  $file) : boolean

Check if file exists

Parameters

string $file

The file to check whether or not it exists.

Returns

boolean —

Whether or not the file exists.

get()

get(string  $file) : string

Get a file from the remote file system.

Parameters

string $file

Path to the file on remote system to retrieve.

Returns

string —

The contents of the file.

get_stream()

get_stream(string  $file) : resource

Get file stream from remote filesystem.

Parameters

string $file

The file path on the remote server to retrieve.

Returns

resource —

The stream resource of the file.

delete()

delete(string  $file) : boolean

Delete file

Parameters

string $file

The file path to delete from remote filesystem.

Returns

boolean —

Whether or not the operation was successful.

rename()

rename(string  $from, string  $dest) : boolean

Rename a file

Parameters

string $from

The from file path.

string $dest

The destination file path.

Returns

boolean —

Whther or not the operation was successful.

copy()

copy(string  $from, string  $dest) : boolean

Copy a file

Parameters

string $from

The from file path.

string $dest

The destination file path.

Returns

boolean —

Whther or not the operation was successful.

create_dir()

create_dir(string  $dir) : boolean

Create a directory

Parameters

string $dir

Path of directory to create.

Returns

boolean —

Whether or not the operation was successful.

delete_dir()

delete_dir(string  $dir) : boolean

Create a directory

Parameters

string $dir

Path of directory to create.

Returns

boolean —

Whether or not the operation was successful.

get_mime_type()

get_mime_type(string  $file) : mixed

Get mime type of file

Parameters

string $file

Parth to the file on the remote filesystem.

Returns

mixed —

The mime type, or false on failure.

get_timestamp()

get_timestamp(string  $file) : mixed

Get timestamps of file

Parameters

string $file

Parth to the file on the remote filesystem.

Returns

mixed —

The last modified time, or false on failure.

get_size()

get_size(string  $file) : mixed

Get size of file

Parameters

string $file

Parth to the file on the remote filesystem.

Returns

mixed —

The file size, or false on failure.