[FileBackend] Added a "ttl" option to getFileHttpUrl().
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 7 Mar 2013 04:47:30 +0000 (20:47 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 7 Mar 2013 04:55:43 +0000 (20:55 -0800)
Change-Id: Ifc7b9c012276ed1f1e436ffafbd5615689680054

includes/filebackend/FileBackend.php
includes/filebackend/SwiftFileBackend.php

index 3ebfdb1..47bc7ac 100644 (file)
@@ -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
         */
index 9c271ea..471cd4b 100644 (file)
@@ -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 ) );