Merge lp:~jacekn/wordpress/openstack-objectstorage-mime-bugfix into lp:~canonical-sysadmins/wordpress/openstack-objectstorage

Proposed by Jacek Nykis
Status: Merged
Merged at revision: 3
Proposed branch: lp:~jacekn/wordpress/openstack-objectstorage-mime-bugfix
Merge into: lp:~canonical-sysadmins/wordpress/openstack-objectstorage
Diff against target: 44 lines (+8/-4)
1 file modified
classes/swift.php (+8/-4)
To merge this branch: bzr merge lp:~jacekn/wordpress/openstack-objectstorage-mime-bugfix
Reviewer Review Type Date Requested Status
The Canonical Sysadmins Pending
Review via email: mp+281995@code.launchpad.net

Description of the change

Ensure we set mime type in swift.

Work around weird behaviour where wordpress thinks SVGs are "image/svg" instead of "image/svg+xml"

To post a comment you must log in.
5. By Jacek Nykis

Whitespace fix (tab vs spaces)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'classes/swift.php'
2--- classes/swift.php 2015-02-11 15:35:31 +0000
3+++ classes/swift.php 2016-01-08 13:31:38 +0000
4@@ -53,9 +53,9 @@
5 return apply_filters( 'swift_setting_' . $key, $value );
6 }
7
8- function uploadFile( $bucket_name, $object_key, $content ) {
9+ function uploadFile( $bucket_name, $object_key, $content, $type ) {
10 $container = $this->swift_get_client()->container($bucket_name);
11- $localObject = new \OpenStack\ObjectStore\v1\Resource\Object($object_key, $content);
12+ $localObject = new \OpenStack\ObjectStore\v1\Resource\Object($object_key, $content, $type);
13 $container->save($localObject);
14 }
15
16@@ -160,6 +160,10 @@
17
18 $type = get_post_mime_type( $post_id );
19
20+ if ( $type == 'image/svg' ) {
21+ $type = 'image/svg+xml';
22+ }
23+
24 $file_path = get_attached_file( $post_id, true );
25
26 $acl = apply_filters( 'wps3_upload_acl', 'public-read', $type, $data, $post_id, $this ); // Old naming convention, will be deprecated soon
27@@ -186,7 +190,7 @@
28 try {
29 $uploaded = file_get_contents($args['SourceFile'] );
30 $newKey = $args['Key'];
31- $this->uploadFile($args['Bucket'], $newKey, $uploaded);
32+ $this->uploadFile($args['Bucket'], $newKey, $uploaded, $type);
33 }
34 catch ( Exception $e ) {
35 error_log( 'Error uploading ' . $file_path . ' to Swift: ' . $e->getMessage() );
36@@ -247,7 +251,7 @@
37
38 $uploaded = file_get_contents($args['SourceFile'] );
39 $newKey = $args['Key'];
40- $this->uploadFile($args['Bucket'], $newKey, $uploaded);
41+ $this->uploadFile($args['Bucket'], $newKey, $uploaded, $type);
42
43 }
44 catch ( Exception $e ) {

Subscribers

People subscribed via source and target branches