From: fabrixxm Date: Wed, 21 Nov 2018 08:38:54 +0000 (+0100) Subject: Add Filesystem storage backend and store photo via backend X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=12dd7b552f382dff38389344b279e3faf6e57281;p=friendica.git Add Filesystem storage backend and store photo via backend --- diff --git a/.gitignore b/.gitignore index 87ce354c1f..345fe69cd9 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,6 @@ venv/ #ignore .htaccess .htaccess + +#ignore filesystem storage default path +/storage \ No newline at end of file diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 078ef87024..3200c7f6ee 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -202,6 +202,17 @@ class Photo extends BaseObject $existing_photo = DBA::selectFirst('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]); + // Get defined storage backend. + // if no storage backend, we use old "data" column in photo table. + $data = ""; + $backend_ref = ""; + $backend_class = Config::get("storage", "class", ""); + if ($backend_class==="") { + $data = $Image->asString(); + } else { + $backend_ref = $backend_class::put($Image->asString()); + } + $fields = [ 'uid' => $uid, 'contact-id' => $cid, @@ -215,14 +226,16 @@ class Photo extends BaseObject 'height' => $Image->getHeight(), 'width' => $Image->getWidth(), 'datasize' => strlen($Image->asString()), - 'data' => $Image->asString(), + 'data' => $data, 'scale' => $scale, 'profile' => $profile, 'allow_cid' => $allow_cid, 'allow_gid' => $allow_gid, 'deny_cid' => $deny_cid, 'deny_gid' => $deny_gid, - 'desc' => $desc + 'desc' => $desc, + 'backend-class' => $backend_class, + 'backend-ref' => $backend_ref ]; if (DBA::isResult($existing_photo)) { diff --git a/src/Model/Storage/Filesystem.php b/src/Model/Storage/Filesystem.php new file mode 100644 index 0000000000..600d93f18b --- /dev/null +++ b/src/Model/Storage/Filesystem.php @@ -0,0 +1,93 @@ +