Merge "[FileBackend] Added a "ttl" option to getFileHttpUrl()."
authorReedy <reedy@wikimedia.org>
Thu, 7 Mar 2013 17:59:48 +0000 (17:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 7 Mar 2013 17:59:48 +0000 (17:59 +0000)
1  2 
includes/filebackend/SwiftFileBackend.php

@@@ -201,7 -201,7 +201,7 @@@ class SwiftFileBackend extends FileBack
                $res = '';
                foreach ( explode( ';', $disposition ) as $part ) {
                        $part = trim( $part );
 -                      $new  = ( $res === '' ) ? $part : "{$res};{$part}";
 +                      $new = ( $res === '' ) ? $part : "{$res};{$part}";
                        if ( strlen( $new ) <= 255 ) {
                                $res = $new;
                        } else {
                                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 ) );