• I have a WordPress Multisite installation where users (students) upload large video files. These are mp4 files created with iMovie.

    For these large files (over 100 MB), Chrome and iOS will not play the videos, although they play fine in Safari and Firefox.

    I have confirmed that IF the files can be served with mime type application/octet-stream, the WordPress automatic embedded player will play them fine on all browsers.

    So I want to force the server to send these files with mime type application/octet-stream.

    Using AddType in .htaccess does not work, because the files are uploaded using the WordPress uploader, and this means that in multisite they are not located where the URL says they should be– instead of mysite.com/files/year/month/filename.mp4, or even at mysite.com/specific-site-in-multisite/files/year/month/filename.mp4 they are at mysite.com/wp-content/blogs.dir/id-number-of-specific-site-in-multisite/files/year/month/filename.mp4

    They are being served (I think) by WordPress php, not by the server itself. So the htaccess AddType directive is not respected for these files at all.

    It seems I have to modify the setting in WordPress, to ask it to serve mp4 as application/octet-stream, rather than video/mp4.

    This is almost what is being asked and answered here–Change the MIME type in WordPress

    But I’m not trying to change allowed upload types, just to change what is served. And I’m not trying to remove an existing type or add a new type, I’m trying to remove an existing type AND add a new replacement type.

    Is that possible? Or is there another way to force the server to send these as application/octet-stream?

Viewing 2 replies - 1 through 2 (of 2 total)
  • This can be done two ways. One is easy, but will be at least problematic with large files like thiat, and the other is harder, but will work everywhere.

    First, you could set up a PHP script to output the headers that you want and basically pass-through the file data. As I said, with large files like yours it can be a big issue and can bog down the server doing all of that extra processing, so I’d suggest to not use this method.

    Secondly, there are server directives that you can add in Apache, and I think can be done using your .htacces file, that can add in headers for a file type that you set. I haven’t had to do this for a (very) long time os I can’t remember off the top of my head what it was, but I do remember that it was possible.

    Thread Starter jugoretz

    (@jugoretz)

    Thanks, catacaustic! Your second method has not been working in my tests, but I will investigate your first. I may also just give up and move the files to Amazon S3, which might be a more sustainable solution anyway.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Mime type change possible?’ is closed to new replies.