Make Swift backend respect Content-Type in create/store
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 26 Oct 2015 18:16:18 +0000 (11:16 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 26 Oct 2015 18:16:18 +0000 (11:16 -0700)
Change-Id: I479d1fc4f261bdcdc380404db0cb2f2397877759

includes/filebackend/SwiftFileBackend.php

index e72d026..83c1da1 100644 (file)
@@ -262,7 +262,9 @@ class SwiftFileBackend extends FileBackendStore {
                }
 
                $sha1Hash = wfBaseConvert( sha1( $params['content'] ), 16, 36, 31 );
-               $contentType = $this->getContentType( $params['dst'], $params['content'], null );
+               $contentType = isset( $params['headers']['content-type'] )
+                       ? $params['headers']['content-type']
+                       : $this->getContentType( $params['dst'], $params['content'], null );
 
                $reqs = array( array(
                        'method' => 'PUT',
@@ -318,7 +320,9 @@ class SwiftFileBackend extends FileBackendStore {
                        return $status;
                }
                $sha1Hash = wfBaseConvert( $sha1Hash, 16, 36, 31 );
-               $contentType = $this->getContentType( $params['dst'], null, $params['src'] );
+               $contentType = isset( $params['headers']['content-type'] )
+                       ? $params['headers']['content-type']
+                       : $this->getContentType( $params['dst'], null, $params['src'] );
 
                $handle = fopen( $params['src'], 'rb' );
                if ( $handle === false ) { // source doesn't exist?