How to use the original mime-type for mp3 files?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
playagiron
Registered User
Posts: 95
Joined: Tue Dec 08, 2009 2:18 pm

How to use the original mime-type for mp3 files?

Post by playagiron »

Support Request Template
What version of phpBB are you using? phpBB 3.3.11
What is your board's URL? https://www.norduserforum.com
Who do you host your board with? all-inkl.com
How did you install your board? I used the download package from phpBB.com
What is the most recent action performed on your board? Fresh Install
Is registration required to reproduce this issue? No
Do you have any MODs installed? No
Do you have any extensions installed? Yes
What extensions do you have installed? board3 Portal
Pages
What styles do you currently have installed? prosilver
What language(s) is your board currently using? english
Which database type/version are you using? MariaDB
What is your level of experience? Experienced with PHP and phpBB
What actions did you take (updating your board; installing a MOD, style or extension; etc.) prior to this problem becoming noticeable? The problem is always there even in a fresh install.
Please describe your problem. I have an mp3 player html5 based that turns uploaded mp3 files into a player.
It works perfectly almost everywhere, but on the MACOS (only in Safari) and iOS (all browsers), they do not playback.

It seems the issue is due to the mime-type not being "mpeg/audio", but as always except for images octet-stream.
So to test, and taking into considerations potential secutory issues, I would like to have downloads having a HTTP header with the mime-type stored in the attachments table (or at least for mp3 files).

I tried it by disabling this part in functions_download.php

Code: Select all

// Correct the mime type - we force application/octetstream for all files, except images
// Please do not change this, it is a security precaution
if ($category != ATTACHMENT_CATEGORY_IMAGE || strpos($attachment['mimetype'], 'image') !== 0)
{
$attachment['mimetype'] = (strpos(strtolower($user->browser), 'msie') !== false || strpos(strtolower($user->browser), 'opera') !== false) ? 'application/octetstream' : 'application/octet-stream';
}
but downloads still had the octetstream mimetype, so might be missing something?


Here an example post where you see the players:
https://www.norduserforum.com/viewtopic.php?t=7456
Generated by SRT Generator
Last edited by thecoalman on Fri May 10, 2024 7:48 am, edited 1 time in total.
Reason: Moved to custom coding.
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6436
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: How to use the original mime-type for mp3 files?

Post by thecoalman »

There is a topic discussing this here.
viewtopic.php?t=2383226
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison

Return to “phpBB Custom Coding”