From: Aaron Schulz Date: Thu, 7 Mar 2013 04:47:30 +0000 (-0800) Subject: [FileBackend] Added a "ttl" option to getFileHttpUrl(). X-Git-Tag: 1.31.0-rc.0~20436^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=66e73f8583698e1e5c15838b85bc9347583c811c;p=lhc%2Fweb%2Fwiklou.git [FileBackend] Added a "ttl" option to getFileHttpUrl(). Change-Id: Ifc7b9c012276ed1f1e436ffafbd5615689680054 --- 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 ) );