mirror of
https://github.com/friendica/friendica
synced 2025-04-25 07:50:10 +00:00
Pluggable storage backends: first steps
- add backend related columns in photo table - add system resource storage class - add code to load image data from backend class - return "nosign" image as photo meta with SystemResource backend
This commit is contained in:
parent
89eaf508f1
commit
3b3c4e8cc7
4 changed files with 83 additions and 10 deletions
39
src/Model/Storage/SystemResource.php
Normal file
39
src/Model/Storage/SystemResource.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* @file src/Model/Storage/SystemStorage.php
|
||||
*/
|
||||
|
||||
namespace Friendica\Model\Storage;
|
||||
|
||||
/**
|
||||
* @brief System resource storage class
|
||||
*
|
||||
* This class is used to load system resources, like images.
|
||||
* Is not itended to be selectable by admins as default storage class.
|
||||
*/
|
||||
class SystemResource
|
||||
{
|
||||
// Valid folders to look for resources
|
||||
const VALID_FOLDERS = [ "images" ];
|
||||
|
||||
/**
|
||||
* @brief get data
|
||||
*
|
||||
* @param string $resourceid
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function get($filename)
|
||||
{
|
||||
$folder = dirname($filename);
|
||||
if (!in_array($folder, self::VALID_FOLDERS)) return "";
|
||||
if (!file_exists($filename)) return "";
|
||||
return file_get_contents($filename);
|
||||
}
|
||||
|
||||
static function put($filename, $data)
|
||||
{
|
||||
throw new \BadMethodCallException();
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue