From 66e73f8583698e1e5c15838b85bc9347583c811c Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 6 Mar 2013 20:47:30 -0800 Subject: [PATCH] [FileBackend] Added a "ttl" option to getFileHttpUrl(). Change-Id: Ifc7b9c012276ed1f1e436ffafbd5615689680054 --- includes/filebackend/FileBackend.php | 1 + includes/filebackend/SwiftFileBackend.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/filebackend/FileBackend.php b/includes/filebackend/FileBackend.php index 3ebfdb1fab..47bc7ac9ad 100644 --- a/includes/filebackend/FileBackend.php +++ b/includes/filebackend/FileBackend.php @@ -1016,6 +1016,7 @@ abstract class FileBackend { * @param $params Array * $params include: * - src : source storage path + * - ttl : lifetime (seconds) if pre-authenticated; default is 1 day * @return string|null * @since 1.21 */ diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 9c271ea2d2..471cd4ba00 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -1210,12 +1210,13 @@ class SwiftFileBackend extends FileBackendStore { return null; // invalid path } try { + $ttl = isset( $params['ttl'] ) ? $params['ttl'] : 86400; $sContObj = $this->getContainer( $srcCont ); $obj = new CF_Object( $sContObj, $srcRel, false, false ); // skip HEAD if ( $this->swiftTempUrlKey != '' ) { - return $obj->get_temp_url( $this->swiftTempUrlKey, 86400, "GET" ); + return $obj->get_temp_url( $this->swiftTempUrlKey, $ttl, "GET" ); } else { // give S3 API URL for rgw - $expires = time() + 86400; + $expires = time() + $ttl; // Path for signature starts with the bucket $spath = '/' . rawurlencode( $srcCont ) . '/' . str_replace( '%2F', '/', rawurlencode( $srcRel ) ); -- 2.20.1