DiskFileStorage
in package
implements
FileStorageDriver
Class DiskFileStorage
This class implements the FileStorageDriver interface and provides functionality for storing and retrieving files on a disk-based storage system.
Table of Contents
Interfaces
- FileStorageDriver
- Interface FileStorageDriver
Properties
- $appUrl : string
- $storageDirectory : string
- $storageUri : string
Methods
- __construct() : mixed
- put() : string
- Stores the given content at the specified path within the storage directory.
Properties
$appUrl
protected
string
$appUrl
The base URL of the application.
$storageDirectory
protected
string
$storageDirectory
The directory path where files are stored on disk.
$storageUri
protected
string
$storageUri
The URI used to access the storage.
Methods
__construct()
public
__construct(string $storageDirectory, string $storageUri, string $appUrl) : mixed
Parameters
- $storageDirectory : string
- $storageUri : string
- $appUrl : string
put()
Stores the given content at the specified path within the storage directory.
public
put(string $path, mixed $content) : string
This method ensures that the storage directory and any necessary subdirectories are created before attempting to write the content to the file. If the operation fails at any point, an exception is thrown.
Parameters
- $path : string
-
The relative path (including the file name) where the content should be stored.
- $content : mixed
-
The content to be written to the file. Can be a string or any serializable data.
Tags
Return values
string —The URL to access the stored file.