Forum Topic: Forcing Mime Type for uploaded files

Forum: .htaccess Forum : WordPress • Posted by Joseph Ugoretz • Updated:

I have a large multisite installation where we have lots of class sites and others where students upload large video files for projects.

The problem we’ve discovered is that (since a recent iMovie update), the mp4 files that iMovie produces, if they’re larger than about 40 MB, will NOT play in Chrome — or iOS (Safari and Firefox are fine).

Students are uploading these files through either the WordPress uploader or Gravity Forms (in either case they end up in the same location, basically).

If the files are served as mime type application/octet-stream (instead of video/mp4) they play just fine — even on iOS.

So I want to use htaccess to define the mimetype for these files as application/octet-stream.

From my research, using AddType in htaccess should do this. And it does fine for files in the root WordPress directory where the htaccess is sitting.

But uploaded files are not in the place where they are expected to be in multisite.

Our install is at http://macaulay.cuny.edu/eportfolios. So the htaccess is there in /eportfolios, and should apply to all subdirectories below that. But even if I put it in the htaccess up above in httpdocs, it has no effect on the files that have been uploaded.

I think this is because the files have a url of

macaulay.cuny.edu/eportfolios/my-site-name/files/year/month/filename

Their actual location is

macaulay.cuny.edu/eportfolios/wp-content/blogs.dir/NUMBER/files/year/month/filename

Could that be it? And if so… is there any way to get that htaccess to apply to those files and follow the redirect?

I tried to put an htaccess in /wp-content, in /blogs.dir, in a specific blogs.dir/number, in blogs.dir/number/files, even in the specific /files/year/month directory. all with no effect. Those files are still being served as video/mp4.

Or should I try fixing this in httpd.conf (where I guess the video/mp4 is coming from)? Would that be more global?

Happy to have any advice I can get!

Thanks.

2 Replies to “Forcing Mime Type for uploaded files”

Posted by Joseph Ugoretz •

Hmmm…

Further research seems to indicate that httpd.conf won’t help either.

My source tells me it’s because because the mp4 files is not being called directly. The file is called via a PHP file and WP determines the mime type.

I guess there has to be a way to override the default mime type in WP?

I’m afraid I’m even more over my head than I thought.

Posted by Jeff Starr

Thanks for the follow-up message.. yes I think you are on the scent with the following:

“I guess there has to be a way to override the default mime type in WP?”

That is what I would look at next. Good luck.