aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Photo.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-07-03 15:58:20 -0700
committerredmatrix <git@macgirvin.com>2016-07-03 15:58:20 -0700
commit57226b2e1378c2769709a2b2407249cc4e3b14f4 (patch)
treefbb6a4713b6ae9c5cb13ab47ffdb1d03a586c820 /Zotlabs/Module/Photo.php
parent17e161006a9ddbfbea3e0b6d5f7776ad7b8101e2 (diff)
parentf46eecc1e7585e64069bb18918a2db057a16c480 (diff)
downloadvolse-hubzilla-57226b2e1378c2769709a2b2407249cc4e3b14f4.tar.gz
volse-hubzilla-57226b2e1378c2769709a2b2407249cc4e3b14f4.tar.bz2
volse-hubzilla-57226b2e1378c2769709a2b2407249cc4e3b14f4.zip
Merge branch 'dev' into perms
Diffstat (limited to 'Zotlabs/Module/Photo.php')
-rw-r--r--Zotlabs/Module/Photo.php30
1 files changed, 27 insertions, 3 deletions
diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php
index 5148c4a94..66aaec49f 100644
--- a/Zotlabs/Module/Photo.php
+++ b/Zotlabs/Module/Photo.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module;
require_once('include/security.php');
+require_once('include/attach.php');
require_once('include/photo/photo_driver.php');
@@ -10,6 +11,8 @@ class Photo extends \Zotlabs\Web\Controller {
function init() {
$prvcachecontrol = false;
+ $streaming = null;
+ $channel = null;
switch(argc()) {
case 4:
@@ -131,6 +134,8 @@ class Photo extends \Zotlabs\Web\Controller {
$sql_extra = permissions_sql($r[0]['uid']);
+ $channel = channelx_by_n($r[0]['uid']);
+
// Now we'll see if we can access the photo
$r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d $sql_extra LIMIT 1",
@@ -141,8 +146,9 @@ class Photo extends \Zotlabs\Web\Controller {
if($r && $allowed) {
$data = dbunescbin($r[0]['content']);
$mimetype = $r[0]['mimetype'];
- if(intval($r[0]['os_storage']))
- $data = file_get_contents($data);
+ if(intval($r[0]['os_storage'])) {
+ $streaming = $data;
+ }
}
else {
@@ -242,7 +248,25 @@ class Photo extends \Zotlabs\Web\Controller {
header("Cache-Control: max-age=" . $cache);
}
- echo $data;
+
+ // If it's a file resource, stream it.
+
+ if($streaming && $channel) {
+ if(strpos($streaming,'store') !== false)
+ $istream = fopen($streaming,'rb');
+ else
+ $istream = fopen('store/' . $channel['channel_address'] . '/' . $streaming,'rb');
+ $ostream = fopen('php://output','wb');
+ if($istream && $ostream) {
+ pipe_streams($istream,$ostream);
+ fclose($istream);
+ fclose($ostream);
+ }
+ }
+ else {
+ echo $data;
+ }
+
killme();
// NOTREACHED
}