summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2015-02-19 11:31:41 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2015-02-19 11:31:41 (GMT)
commitcb8e60fc25af3bdf107a119c8f63050df37f1986 (patch)
treecd3ed8f72654abd713167190ceb5c4f3018d9536
parent20f77bb71f171c6d9b0149db548d20c00a6096b6 (diff)
downloadkolab-chwala-cb8e60fc25af3bdf107a119c8f63050df37f1986.tar.gz
Fix viewing (binary) files from SeaFile (#4590)
-rw-r--r--lib/drivers/seafile/seafile_api.php4
-rw-r--r--lib/drivers/seafile/seafile_file_storage.php13
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/drivers/seafile/seafile_api.php b/lib/drivers/seafile/seafile_api.php
index f3ec251..fd08f8b 100644
--- a/lib/drivers/seafile/seafile_api.php
+++ b/lib/drivers/seafile/seafile_api.php
@@ -109,6 +109,10 @@ class seafile_api
'ssl_cafile', 'ssl_capath', 'ssl_local_cert', 'ssl_passphrase'
)));
+ // force CURL adapter, this allows to handle correctly
+ // compressed responses with simple SplObserver registered
+ $config['adapter'] = 'HTTP_Request2_Adapter_Curl';
+
try {
$request = new HTTP_Request2();
$request->setConfig($config);
diff --git a/lib/drivers/seafile/seafile_file_storage.php b/lib/drivers/seafile/seafile_file_storage.php
index 95c3f88..c9c6aac 100644
--- a/lib/drivers/seafile/seafile_file_storage.php
+++ b/lib/drivers/seafile/seafile_file_storage.php
@@ -507,8 +507,21 @@ class seafile_file_storage implements file_storage
// just send redirect to SeaFile server
if ($file['size']) {
+ // In view-mode we can't redirect to SeaFile server because:
+ // - it responds with Content-Disposition: attachment, which causes that
+ // e.g. previewing images is not possible
+ // - pdf/odf viewers can't follow redirects for some reason (#4590)
+ if (empty($params['force-download'])) {
+ if ($fp = fopen('php://output', 'wb')) {
+ $this->save_file_content($link, $fp);
+ fclose($fp);
+ die;
+ }
+ }
+
header("Location: $link");
}
+
die;
}