4 deleted 228 characters in body
source | link

The resulting file is identical regardless of the link that you use. I downloaded the file via each link and compared the files, they are identical.

So the conclusion is that it's a matter of headers. What I get from the ms-blogs version of the url is:

Content-Type: application/msword

Versus what I get from direct link:

Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Which appears to be a type which Google Docs understands.

My concluson is that the MIME type that WordPress provides for this file, application/msword, is not one that Google Docs understands.

You can fix this by filtering upload_mimes, and changing the result MIME type for .docx files to match the correct one that Google Docs understands:

function my_filter_upload_mimes( $mimes ) {
     $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     return $mimes;
}
add_filter( 'upload_mimes', 'my_filter_upload_mimes' );

WordPress uses this filter in the function get_allowed_mime_types(), which is used by wp_check_filetype() to determine the output MIME type in wp-includes/ms-files.php

Update

wp-includes/ms-files.php uses SHORTINIT, so themes are not loaded, and thus the above code will not work if you place it in your theme code.

Plugins, on the other hand, will still be loaded even with SHORTINIT enabled.Plugins, on the other hand, will still be loaded even with SHORTINIT enabled.

(Edit by Otto: This is incorrect, SHORTINIT prevents plugin loading. See wp-settings.php, around line 95 for where the SHORTINIT flag cuts off the loading process, and note that plugins load after that. The following code will not work.)

Create a file wp-content/plugins/re-mime.php, with contents:

<?php
/*
Plugin Name: RE-MIME
*/
function re_mime_filter_upload_mimes( $mimes ) {
  $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
  return $mimes;
}
add_filter( 'upload_mimes', 're_mime_filter_upload_mimes' );

And enable this plugin Network-Wide. This will set the MIME type correctly for doc and docx files so that Google Docs will understand.(Edit by Bendoh: D'oh! I had commented out the SHORTINIT declaration while testing and thus my solution did work, but you're correct that it won't work without mucking with core. I removed the code below as it doesn't actually work. Otto's answer is correct)

The resulting file is identical regardless of the link that you use. I downloaded the file via each link and compared the files, they are identical.

So the conclusion is that it's a matter of headers. What I get from the ms-blogs version of the url is:

Content-Type: application/msword

Versus what I get from direct link:

Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Which appears to be a type which Google Docs understands.

My concluson is that the MIME type that WordPress provides for this file, application/msword, is not one that Google Docs understands.

You can fix this by filtering upload_mimes, and changing the result MIME type for .docx files to match the correct one that Google Docs understands:

function my_filter_upload_mimes( $mimes ) {
     $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     return $mimes;
}
add_filter( 'upload_mimes', 'my_filter_upload_mimes' );

WordPress uses this filter in the function get_allowed_mime_types(), which is used by wp_check_filetype() to determine the output MIME type in wp-includes/ms-files.php

Update

wp-includes/ms-files.php uses SHORTINIT, so themes are not loaded, and thus the above code will not work if you place it in your theme code.

Plugins, on the other hand, will still be loaded even with SHORTINIT enabled.

(Edit by Otto: This is incorrect, SHORTINIT prevents plugin loading. See wp-settings.php, around line 95 for where the SHORTINIT flag cuts off the loading process, and note that plugins load after that. The following code will not work.)

Create a file wp-content/plugins/re-mime.php, with contents:

<?php
/*
Plugin Name: RE-MIME
*/
function re_mime_filter_upload_mimes( $mimes ) {
  $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
  return $mimes;
}
add_filter( 'upload_mimes', 're_mime_filter_upload_mimes' );

And enable this plugin Network-Wide. This will set the MIME type correctly for doc and docx files so that Google Docs will understand.

The resulting file is identical regardless of the link that you use. I downloaded the file via each link and compared the files, they are identical.

So the conclusion is that it's a matter of headers. What I get from the ms-blogs version of the url is:

Content-Type: application/msword

Versus what I get from direct link:

Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Which appears to be a type which Google Docs understands.

My concluson is that the MIME type that WordPress provides for this file, application/msword, is not one that Google Docs understands.

You can fix this by filtering upload_mimes, and changing the result MIME type for .docx files to match the correct one that Google Docs understands:

function my_filter_upload_mimes( $mimes ) {
     $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     return $mimes;
}
add_filter( 'upload_mimes', 'my_filter_upload_mimes' );

WordPress uses this filter in the function get_allowed_mime_types(), which is used by wp_check_filetype() to determine the output MIME type in wp-includes/ms-files.php

Update

wp-includes/ms-files.php uses SHORTINIT, so themes are not loaded, and thus the above code will not work if you place it in your theme code.

Plugins, on the other hand, will still be loaded even with SHORTINIT enabled.

(Edit by Otto: This is incorrect, SHORTINIT prevents plugin loading. See wp-settings.php, around line 95 for where the SHORTINIT flag cuts off the loading process, and note that plugins load after that. The following code will not work.)

(Edit by Bendoh: D'oh! I had commented out the SHORTINIT declaration while testing and thus my solution did work, but you're correct that it won't work without mucking with core. I removed the code below as it doesn't actually work. Otto's answer is correct)

    Bounty Ended with 50 reputation awarded by Ünsal Korkmaz
3 added 243 characters in body
source | link

The resulting file is identical regardless of the link that you use. I downloaded the file via each link and compared the files, they are identical.

So the conclusion is that it's a matter of headers. What I get from the ms-blogs version of the url is:

Content-Type: application/msword

Versus what I get from direct link:

Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Which appears to be a type which Google Docs understands.

My concluson is that the MIME type that WordPress provides for this file, application/msword, is not one that Google Docs understands.

You can fix this by filtering upload_mimes, and changing the result MIME type for .docx files to match the correct one that Google Docs understands:

function my_filter_upload_mimes( $mimes ) {
     $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     return $mimes;
}
add_filter( 'upload_mimes', 'my_filter_upload_mimes' );

WordPress uses this filter in the function get_allowed_mime_types(), which is used by wp_check_filetype() to determine the output MIME type in wp-includes/ms-files.php

Update

wp-includes/ms-files.php uses SHORTINIT, so themes are not loaded, and thus the above code will not work if you place it in your theme code.

Plugins, on the other hand, will still be loaded even with SHORTINIT enabled.

(Edit by Otto: This is incorrect, SHORTINIT prevents plugin loading. See wp-settings.php, around line 95 for where the SHORTINIT flag cuts off the loading process, and note that plugins load after that. The following code will not work.)

Create a file wp-content/plugins/re-mime.php, with contents:

<?php
/*
Plugin Name: RE-MIME
*/
function re_mime_filter_upload_mimes( $mimes ) {
  $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
  return $mimes;
}
add_filter( 'upload_mimes', 're_mime_filter_upload_mimes' );

And enable this plugin Network-Wide. This will set the MIME type correctly for doc and docx files so that Google Docs will understand.

The resulting file is identical regardless of the link that you use. I downloaded the file via each link and compared the files, they are identical.

So the conclusion is that it's a matter of headers. What I get from the ms-blogs version of the url is:

Content-Type: application/msword

Versus what I get from direct link:

Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Which appears to be a type which Google Docs understands.

My concluson is that the MIME type that WordPress provides for this file, application/msword, is not one that Google Docs understands.

You can fix this by filtering upload_mimes, and changing the result MIME type for .docx files to match the correct one that Google Docs understands:

function my_filter_upload_mimes( $mimes ) {
     $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     return $mimes;
}
add_filter( 'upload_mimes', 'my_filter_upload_mimes' );

WordPress uses this filter in the function get_allowed_mime_types(), which is used by wp_check_filetype() to determine the output MIME type in wp-includes/ms-files.php

Update

wp-includes/ms-files.php uses SHORTINIT, so themes are not loaded, and thus the above code will not work if you place it in your theme code.

Plugins, on the other hand, will still be loaded even with SHORTINIT enabled.

Create a file wp-content/plugins/re-mime.php, with contents:

<?php
/*
Plugin Name: RE-MIME
*/
function re_mime_filter_upload_mimes( $mimes ) {
  $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
  return $mimes;
}
add_filter( 'upload_mimes', 're_mime_filter_upload_mimes' );

And enable this plugin Network-Wide. This will set the MIME type correctly for doc and docx files so that Google Docs will understand.

The resulting file is identical regardless of the link that you use. I downloaded the file via each link and compared the files, they are identical.

So the conclusion is that it's a matter of headers. What I get from the ms-blogs version of the url is:

Content-Type: application/msword

Versus what I get from direct link:

Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Which appears to be a type which Google Docs understands.

My concluson is that the MIME type that WordPress provides for this file, application/msword, is not one that Google Docs understands.

You can fix this by filtering upload_mimes, and changing the result MIME type for .docx files to match the correct one that Google Docs understands:

function my_filter_upload_mimes( $mimes ) {
     $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     return $mimes;
}
add_filter( 'upload_mimes', 'my_filter_upload_mimes' );

WordPress uses this filter in the function get_allowed_mime_types(), which is used by wp_check_filetype() to determine the output MIME type in wp-includes/ms-files.php

Update

wp-includes/ms-files.php uses SHORTINIT, so themes are not loaded, and thus the above code will not work if you place it in your theme code.

Plugins, on the other hand, will still be loaded even with SHORTINIT enabled.

(Edit by Otto: This is incorrect, SHORTINIT prevents plugin loading. See wp-settings.php, around line 95 for where the SHORTINIT flag cuts off the loading process, and note that plugins load after that. The following code will not work.)

Create a file wp-content/plugins/re-mime.php, with contents:

<?php
/*
Plugin Name: RE-MIME
*/
function re_mime_filter_upload_mimes( $mimes ) {
  $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
  return $mimes;
}
add_filter( 'upload_mimes', 're_mime_filter_upload_mimes' );

And enable this plugin Network-Wide. This will set the MIME type correctly for doc and docx files so that Google Docs will understand.

2 Added plugin instructions because themes are not loaded by wp-includes/ms-files.php
source | link

The resulting file is identical regardless of the link that you use. I downloaded the file via each link and compared the files, they are identical.

So the conclusion is that it's a matter of headers. What I get from the ms-blogs version of the url is:

Content-Type: application/msword

Versus what I get from direct link:

Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Which appears to be a type which Google Docs understands.

My concluson is that the MIME type that WordPress provides for this file, application/msword, is not one that Google Docs understands.

You can fix this by filtering upload_mimes, and changing the result MIME type for .docx files to match the correct one that Google Docs understands:

function my_filter_upload_mimes( $mimes ) {
     $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     return $mimes;
}
add_filter( 'upload_mimes', 'my_filter_upload_mimes' );

WordPress uses this filter in the function get_allowed_mime_types(), which is used by wp_check_filetype() to determine the output MIME type in wp-includes/ms-files.php

Update

wp-includes/ms-files.php uses SHORTINIT, so themes are not loaded, and thus the above code will not work if you place it in your theme code.

Plugins, on the other hand, will still be loaded even with SHORTINIT enabled.

Create a file wp-content/plugins/re-mime.php, with contents:

<?php
/*
Plugin Name: RE-MIME
*/
function re_mime_filter_upload_mimes( $mimes ) {
  $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
  return $mimes;
}
add_filter( 'upload_mimes', 're_mime_filter_upload_mimes' );

And enable this plugin Network-Wide. This will set the MIME type correctly for doc and docx files so that Google Docs will understand.

The resulting file is identical regardless of the link that you use. I downloaded the file via each link and compared the files, they are identical.

So the conclusion is that it's a matter of headers. What I get from the ms-blogs version of the url is:

Content-Type: application/msword

Versus what I get from direct link:

Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Which appears to be a type which Google Docs understands.

My concluson is that the MIME type that WordPress provides for this file, application/msword, is not one that Google Docs understands.

You can fix this by filtering upload_mimes, and changing the result MIME type for .docx files to match the correct one that Google Docs understands:

function my_filter_upload_mimes( $mimes ) {
     $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     return $mimes;
}
add_filter( 'upload_mimes', 'my_filter_upload_mimes' );

WordPress uses this filter in the function get_allowed_mime_types(), which is used by wp_check_filetype() to determine the output MIME type in wp-includes/ms-files.php

The resulting file is identical regardless of the link that you use. I downloaded the file via each link and compared the files, they are identical.

So the conclusion is that it's a matter of headers. What I get from the ms-blogs version of the url is:

Content-Type: application/msword

Versus what I get from direct link:

Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Which appears to be a type which Google Docs understands.

My concluson is that the MIME type that WordPress provides for this file, application/msword, is not one that Google Docs understands.

You can fix this by filtering upload_mimes, and changing the result MIME type for .docx files to match the correct one that Google Docs understands:

function my_filter_upload_mimes( $mimes ) {
     $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     return $mimes;
}
add_filter( 'upload_mimes', 'my_filter_upload_mimes' );

WordPress uses this filter in the function get_allowed_mime_types(), which is used by wp_check_filetype() to determine the output MIME type in wp-includes/ms-files.php

Update

wp-includes/ms-files.php uses SHORTINIT, so themes are not loaded, and thus the above code will not work if you place it in your theme code.

Plugins, on the other hand, will still be loaded even with SHORTINIT enabled.

Create a file wp-content/plugins/re-mime.php, with contents:

<?php
/*
Plugin Name: RE-MIME
*/
function re_mime_filter_upload_mimes( $mimes ) {
  $mimes['doc|docx'] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
  return $mimes;
}
add_filter( 'upload_mimes', 're_mime_filter_upload_mimes' );

And enable this plugin Network-Wide. This will set the MIME type correctly for doc and docx files so that Google Docs will understand.

1
source | link